Skip to content

feat(java/driver/flight-sql): support flightsql:// URI scheme#4539

Open
unikdahal wants to merge 1 commit into
apache:mainfrom
unikdahal:flightsql-uri-scheme
Open

feat(java/driver/flight-sql): support flightsql:// URI scheme#4539
unikdahal wants to merge 1 commit into
apache:mainfrom
unikdahal:flightsql-uri-scheme

Conversation

@unikdahal

Copy link
Copy Markdown

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 default
  • flightsql://<host>:<port>?transport=tls — explicit TLS
  • flightsql://<host>:<port>?transport=tcp — plaintext gRPC
  • flightsql:///<path/to/socket>?transport=unix — Unix domain socket

The transport value is matched case-insensitively; an unrecognized value is rejected with INVALID_ARGUMENT rather than silently falling back. Invalid
combinations (socket path with tcp/tls, host with unix, missing host/path) are rejected, matching the Go driver's validation and error messages. The
legacy grpc://, grpc+tcp://, grpc+tls://, and grpc+unix:// schemes are still accepted unchanged.

URIs with userinfo or a fragment are rejected explicitly, since Location would otherwise drop them silently. Parse failures that java.net.URI reports only
via Location's IllegalArgumentException (e.g. hostnames that fail strict authority parsing) are caught and surfaced as INVALID_ARGUMENT AdbcExceptions.

FlightSqlDatabase#toString now reports the originally configured URI alongside the resolved target.

Testing

  • New FlightSqlDriverUriTest: 18 unit tests covering translation of all transports, case-insensitivity, legacy scheme passthrough, a real connection over
    ?transport=tcp against an in-process Flight server, and rejection cases (unrecognized transport, invalid host/path combinations, userinfo, fragment, malformed
    percent-encoding, unparseable hosts).
  • Two TLS tests added to TlsTest exercising flightsql:// default and explicit ?transport=tls against the TLS test server.

Closes #4516. Part of #4453.

@unikdahal
unikdahal requested a review from lidavidm as a code owner July 19, 2026 22:38
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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.parseLocation to translate/validate flightsql://... URIs (default TLS; transport=tcp|tls|unix case-insensitive; reject invalid combinations, userinfo, fragments, and malformed percent-encoding in transport).
  • Add a new FlightSqlDriverUriTest suite covering translations, rejections, and a real TCP connection against an in-process server.
  • Update TlsTest to cover flightsql:// default TLS and explicit ?transport=tls, and update FlightSqlDatabase#toString to 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.

Comment on lines +96 to +98
if (!FLIGHTSQL_SCHEME.equals(parsed.getScheme())) {
return new Location(parsed);
}
Comment on lines 83 to +88
public String toString() {
return "FlightSqlDatabase{" + "target='" + location + '\'' + '}';
Object configuredUri = AdbcDriver.PARAM_URI.get(parameters);
if (configuredUri == null) {
configuredUri = parameters.get(AdbcDriver.PARAM_URL);
}
return "FlightSqlDatabase{" + "uri='" + configuredUri + "', target='" + location + '\'' + '}';
Comment on lines +118 to +123
@Test
void rejectsHostWithUnixTransport() {
assertThrows(
AdbcException.class,
() -> FlightSqlDriver.parseLocation("flightsql://localhost:1234/socket?transport=unix"));
}
Comment on lines +125 to +130
@Test
void rejectsPathWithTcpTransport() {
assertThrows(
AdbcException.class,
() -> FlightSqlDriver.parseLocation("flightsql://localhost:1234/socket?transport=tcp"));
}
Comment on lines +132 to +137
@Test
void rejectsPathWithDefaultTransport() {
assertThrows(
AdbcException.class,
() -> FlightSqlDriver.parseLocation("flightsql://localhost:1234/socket"));
}
Comment on lines +139 to +143
@Test
void rejectsUnixTransportWithoutPath() {
assertThrows(
AdbcException.class, () -> FlightSqlDriver.parseLocation("flightsql://?transport=unix"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

java/driver/flight-sql: add support for URIs that begin with flightsql://

2 participants