feat(java/driver/flight-sql): implement Flight SQL session management#4444
Open
unikdahal wants to merge 1 commit into
Open
feat(java/driver/flight-sql): implement Flight SQL session management#4444unikdahal wants to merge 1 commit into
unikdahal wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 forsession option key prefixes:
adbc.flight.sql.session.option.(string/long/double)adbc.flight.sql.session.optionbool.(boolean)adbc.flight.sql.session.optionstringlist.(String[]; JSON stringalso 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— addssetSessionOptions,getSessionOptions, andcloseSessiondelegation methods following theexisting
combine(callOptions)pattern.FlightSqlConnection— overridesgetOption/setOptionfor allsession prefixes with typed dispatch via
TypedKey<T>:nullvalue rejected early withINVALID_ARGUMENTINVALID_ARGUMENTLong/Doubleparse errors wrapped inAdbcExceptioninstead ofleaking
NumberFormatExceptionclose()sendsCloseSessionbest-effort; catches onlyFlightRuntimeExceptionsoInterruptedExceptionis never swallowedFlightSqlSessionUtil(new class) — package-private utilityholding all JSON helpers and typed
SessionOptionValuevisitors,extracted from
FlightSqlConnectionto keep the connection classfocused on the ADBC surface:
escapeJsoncovers the full U+0000–U+001F control-character rangeparseJsonArrayhandles\uXXXX,\b,\f, and all JSONwhitespace (not just ASCII space)
JSON_VALUE_VISITORemits"null"forNaN/Infinitydoubles toproduce valid RFC 8259 output
FlightSqlSessionTest(new tests) — 8 unit tests using anin-process
FlightSqlProducerwith real in-memory session state,covering: string/bool/string-list set+get, erase, the full
SESSION_OPTIONSJSON blob,CloseSessioncalled onclose(),read-only blob rejection, and graceful close when server returns
produce valid RFC 8259 output
FlightSqlSessionTest(new tests) — 8 unit tests using anin-process
FlightSqlProducerwith real in-memory session state,covering: string/bool/string-list set+get, erase, the full
SESSION_OPTIONSJSON blob,CloseSessioncalled onclose(),read-only blob rejection, and graceful close when server returns
UNIMPLEMENTED.