Skip to content

feat(java/driver/flight-sql): implement Flight SQL session management#4444

Open
unikdahal wants to merge 1 commit into
apache:mainfrom
unikdahal:main
Open

feat(java/driver/flight-sql): implement Flight SQL session management#4444
unikdahal wants to merge 1 commit into
apache:mainfrom
unikdahal:main

Conversation

@unikdahal

Copy link
Copy Markdown

Summary

Implements Flight SQL session management in the Java ADBC driver,
bringing parity with the Go/Python drivers. Relates to #745. Closes
#4443.

Changes

FlightSqlConnectionProperties — adds five string constants for
session option key prefixes:

  • adbc.flight.sql.session.option. (string/long/double)
  • adbc.flight.sql.session.optionbool. (boolean)
  • adbc.flight.sql.session.optionstringlist. (String[]; JSON string
    also accepted for cross-language compat)
  • adbc.flight.sql.session.optionerase. (erase an option)
  • adbc.flight.sql.session.options (read-only JSON blob of all options)

FlightSqlClientWithCallOptions — adds setSessionOptions,
getSessionOptions, and closeSession delegation methods following the
existing combine(callOptions) pattern.

FlightSqlConnection — overrides getOption/setOption for all
session prefixes with typed dispatch via TypedKey<T>:

  • null value rejected early with INVALID_ARGUMENT
  • Empty option name caught before the RPC with INVALID_ARGUMENT
  • Long/Double parse errors wrapped in AdbcException instead of
    leaking NumberFormatException
  • close() sends CloseSession best-effort; catches only
    FlightRuntimeException so InterruptedException is never swallowed

FlightSqlSessionUtil (new class) — package-private utility
holding all JSON helpers and typed SessionOptionValue visitors,
extracted from FlightSqlConnection to keep the connection class
focused on the ADBC surface:

  • escapeJson covers the full U+0000–U+001F control-character range
  • parseJsonArray handles \uXXXX, \b, \f, and all JSON
    whitespace (not just ASCII space)
  • JSON_VALUE_VISITOR emits "null" for NaN/Infinity doubles to
    produce valid RFC 8259 output

FlightSqlSessionTest (new tests) — 8 unit tests using an
in-process FlightSqlProducer with real in-memory session state,
covering: string/bool/string-list set+get, erase, the full
SESSION_OPTIONS JSON blob, CloseSession called on close(),
read-only blob rejection, and graceful close when server returns
produce valid RFC 8259 output

FlightSqlSessionTest (new tests) — 8 unit tests using an
in-process FlightSqlProducer with real in-memory session state,
covering: string/bool/string-list set+get, erase, the full
SESSION_OPTIONS JSON blob, CloseSession called on close(),
read-only blob rejection, and graceful close when server returns
UNIMPLEMENTED.

Wires Flight SQL session options and CloseSession into the Java ADBC
driver, bringing it to parity with the Go/Python drivers.

What changed:

FlightSqlConnectionProperties — five new string constants for session
option key prefixes (adbc.flight.sql.session.option.,
adbc.flight.sql.session.optionbool.,
adbc.flight.sql.session.optionstringlist.,
adbc.flight.sql.session.optionerase., and the read-only
adbc.flight.sql.session.options JSON blob key).

FlightSqlClientWithCallOptions — three new delegation methods:
setSessionOptions, getSessionOptions, closeSession, all forwarding
connectionOptions via the existing combine() pattern.

FlightSqlConnection — overrides getOption/setOption on AdbcConnection
for all session key prefixes; each typed prefix (string, bool,
stringlist, long, double) dispatches to the appropriate
SessionOptionValue via a visitor. setOption null value is rejected early
with INVALID_ARGUMENT. The erase prefix calls makeEmptySessionOptionValue.
close() now sends CloseSession best-effort, catching only
FlightRuntimeException so InterruptedException is not swallowed.

FlightSqlSessionUtil — new package-private class holding all JSON
helpers (sessionOptionsToJson, toJsonArray, parseJsonArray, escapeJson)
and the six typed SessionOptionValue visitors. Extracted from
FlightSqlConnection to keep that class focused on the ADBC surface.
escapeJson handles the full U+0000-U+001F control-character range.
parseJsonArray handles \uXXXX, \b, \f and all JSON whitespace.
JSON_VALUE_VISITOR emits "null" for NaN/Infinity doubles to produce
valid RFC 8259 output.

FlightSqlSessionTest — new unit tests covering set/get for string, bool,
and string-list option types, erase, the full SESSION_OPTIONS JSON blob,
CloseSession being called on close(), read-only blob rejection, and
close() not throwing when the server returns UNIMPLEMENTED.

Relates to apache#745. Closes apache#4443.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@unikdahal unikdahal requested a review from lidavidm as a code owner June 26, 2026 21:53
@unikdahal unikdahal changed the title feat(java/driver/flight-sql): implement Flight SQL session management (#4443) feat(java/driver/flight-sql): implement Flight SQL session management Jun 26, 2026
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.

1 participant