-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(java/driver/flight-sql): implement getObjects #1517
Conversation
This incorporates the work from #605 . However I'm examining the Go Flight SQL ADBC driver to see if I can port some of its implementation here to cover the cases missing (empty catalogs or schemas). |
@jduo yeah, either that or you will have to preprocess to get those missing cases and add them in correctly sorted order during normal processing. Good thing is that you won't have to keep much of it in some local object in-memory unlike go implementation but the code might get really ugly. |
For this iteration I'm going to assume the server returns data in the correct order and doesn't do anything crazy such as split the columns from one table across separate partitions. |
bc44112
to
dfff096
Compare
I'm almost done writing the implementation of this. It turned out to be a fairly complicated ordeal to compress/denormalize the flattened data from Flight SQL to ADBC's nested lists of structs. A couple of things:
|
2e0009a
to
e527e25
Compare
* Change GetSqlInfo and GetObjects to use the same reader as FlightInfoReader. This fixes bugs where locations aren't used for these metadata calls and also makes them use resources lazily. * Fix a bug in the FlightInfoReader path where the first stream is assumed to be from the current client rather than using a location in the first endpoint. * Fix handling of empty schemas or empty collections when using GetObjects.
Fix NPEs and not propagating credentials for some calls
50051ba
to
c90881d
Compare
This PR supports getting catalogs, schemas, tables, and columns. Tests include:
|
<!-- Helpers for mapping Arrow types to ANSI SQL types and building test servers --> | ||
<dependency> | ||
<groupId>org.apache.arrow</groupId> | ||
<artifactId>flight-sql-jdbc-core</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a heavy dependency to have to pull in, unfortunately
// Checker framework is considering Arrow functions such as FlightStream.next() as potentially | ||
// altering the state | ||
// and able to change currentStream or schema fields to null. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, usually I've gotten around this by doing the equivalent of
if (field == null) {
throw;
}
T localField = field; // never null now
// TODO: actual version | ||
setStringValue(dstIndex++, "0.0.1".getBytes(StandardCharsets.UTF_8)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we file an issue for this? (I see it was there originally)
if (JAVA_REGEX_SPECIALS.indexOf(currentChar) >= 0) { | ||
javaPattern.append('\\'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you only want to do this if it's not a _
or %
?
Also, you could just always apply Pattern.quote instead of hardcoding the potential special characters?
// This is taken from the JDBC driver, but seems wrong that all three branches write the same | ||
// value. | ||
// Float should probably be 2. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we file an issue?
@SuppressWarnings( | ||
"method.invocation") // Checker Framework does not like the ensureInitialized call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It needs to be properly annotated upstream (CC @davisusanibar)
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've been using JUnit5, can we stick to that? Or does the TestRule force us onto JUnit 4? (If so, can we file issues to fix this?)
Fixes #745