feat(java/driver/flight-sql): support flightsql:// URI scheme - #4539
feat(java/driver/flight-sql): support flightsql:// URI scheme#4539unikdahal wants to merge 3 commits into
Conversation
Mirrors Go's flightsql:// scheme (transport=tls/tcp/unix query param, default TLS, legacy grpc*:// schemes still accepted). Translates to Location's grpc+tls/grpc+tcp/grpc+unix schemes with explicit validation of host/path combinations per transport.
There was a problem hiding this comment.
Pull request overview
Adds flightsql:// URI support to the Java Flight SQL ADBC driver (aligning with the Go driver), including transport selection via a transport query parameter and tighter validation/error surfacing. This updates URI parsing to translate flightsql:// into the legacy grpc+{tls,tcp,unix}:// forms that Arrow Flight Location understands, and expands test coverage for the new scheme.
Changes:
- Add
FlightSqlDriver.parseLocationto translate/validateflightsql://...URIs (default TLS;transport=tcp|tls|unixcase-insensitive; reject invalid combinations, userinfo, fragments, and malformed percent-encoding intransport). - Add a new
FlightSqlDriverUriTestsuite covering translations, rejections, and a real TCP connection against an in-process server. - Update
TlsTestto coverflightsql://default TLS and explicit?transport=tls, and updateFlightSqlDatabase#toStringto include configured URI.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| java/driver/flight-sql/src/main/java/org/apache/arrow/adbc/driver/flightsql/FlightSqlDriver.java | Implements flightsql:// parsing/translation and validation into Flight Location. |
| java/driver/flight-sql/src/main/java/org/apache/arrow/adbc/driver/flightsql/FlightSqlDatabase.java | Enhances toString() to report configured URI alongside resolved target. |
| java/driver/flight-sql/src/test/java/org/apache/arrow/adbc/driver/flightsql/FlightSqlDriverUriTest.java | Adds unit/integration tests for new scheme behavior and validation. |
| java/driver/flight-sql/src/test/java/org/apache/arrow/adbc/driver/flightsql/TlsTest.java | Adds TLS coverage for flightsql:// default and explicit TLS transport. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
java/driver/flight-sql/src/test/java/org/apache/arrow/adbc/driver/flightsql/TlsTest.java:191
AdbcDatabaseis created but never closed. Use try-with-resources so database (and any underlying resources) are always released, even ifconnect()throws.
@Test
public void testClientFlightSqlSchemeExplicitTlsTransport() throws Exception {
params.put(AdbcDriver.PARAM_URI.getKey(), getFlightSqlUri("tls"));
params.put(FlightSqlConnectionProperties.TLS_SKIP_VERIFY.getKey(), true);
AdbcDatabase db =
AdbcDriverManager.getInstance()
.connect(FlightSqlDriverFactory.class.getCanonicalName(), allocator, params);
try (AdbcConnection conn = db.connect()) {}
}
What's Changed
Adds support for
flightsql://URIs to the Java Flight SQL driver, mirroring the Go driver's implementation (#4488).flightsql://<host>:<port>— secure TLS by defaultflightsql://<host>:<port>?transport=tls— explicit TLSflightsql://<host>:<port>?transport=tcp— plaintext gRPCflightsql:///<path/to/socket>?transport=unix— Unix domain socketThe
transportvalue is matched case-insensitively; an unrecognized value is rejected withINVALID_ARGUMENTrather than silently falling back. Invalidcombinations (socket path with
tcp/tls, host withunix, missing host/path) are rejected, matching the Go driver's validation and error messages. Thelegacy
grpc://,grpc+tcp://,grpc+tls://, andgrpc+unix://schemes are still accepted unchanged.URIs with userinfo or a fragment are rejected explicitly, since
Locationwould otherwise drop them silently. Parse failures thatjava.net.URIreports onlyvia
Location'sIllegalArgumentException(e.g. hostnames that fail strict authority parsing) are caught and surfaced asINVALID_ARGUMENTAdbcExceptions.Testing
FlightSqlDriverUriTest: 18 unit tests covering translation of all transports, case-insensitivity, legacy scheme passthrough, a real connection over?transport=tcpagainst an in-process Flight server, and rejection cases (unrecognized transport, invalid host/path combinations, userinfo, fragment, malformedpercent-encoding, unparseable hosts).
TlsTestexercisingflightsql://default and explicit?transport=tlsagainst the TLS test server.Closes #4516. Part of #4453.