Repository navigation
fix(metadata + reader): match Thrift wire types and wire manifest augmenter - #34
Merged
Merged
Conversation
…ATA_TYPE The Thrift backend's `GetColumns` RPC ships two of the JDBC `getColumns` integer columns with narrower types than the JDBC spec: BUFFER_LENGTH: Thrift TINYINT vs JDBC Types.INTEGER SOURCE_DATA_TYPE: Thrift SMALLINT vs JDBC Types.SMALLINT JDBC spec says `Types.INTEGER` for BUFFER_LENGTH and `Types.SMALLINT` for SOURCE_DATA_TYPE. We previously emitted Int32 for both to keep the schema uniform; that left an unnecessary diff with Thrift's wire format (`tinyint` and `smallint`) when running the comparator. Switch to Int8 / Int16 to match Thrift exactly. The values are always null (no server-side source), so the narrower range has no practical effect. Closes 1 comparator case (the `list_columns(catalog='nonexistent')` schema check). Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.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
Two related fixes:
1. Match Thrift's wire types for
BUFFER_LENGTHandSOURCE_DATA_TYPEBUFFER_LENGTHInt32Int8TINYINTTypes.INTEGERSOURCE_DATA_TYPEInt32Int16SMALLINTTypes.SMALLINTJDBC spec says
Types.INTEGER/Types.SMALLINT. Thrift'sGetColumnsRPC happens to shipBUFFER_LENGTHasTINYINT(HiveServer2-era wire quirk) andSOURCE_DATA_TYPEasSMALLINT. Matching Thrift's narrower types makes the kernel backend a closer drop-in. Both columns are always null (no server source), so the narrower ranges have no practical effect.2. Wire
ManifestAugmentingReaderintoexecute_and_readaugment_schema_with_manifestwas added onResultReaderAdapterto attach Databricks-specific per-column metadata from the SEAResultManifest(databricks.type_name,databricks.type_text, precision, scale, interval kind). But the augmenter was only reachable throughResultReaderAdapter(Arrow-FFI shape); the live execute path uses the kernel's ownResultReadertrait directly, so the metadata was never actually present onResultStream::schema()consumers.Introduce
ManifestAugmentingReader— a thin wrapper implementing the kernel'sResultReadertrait, exposing the augmented schema viaschema(), and re-projecting each emittedRecordBatchonto that schema sobatch.schema()carries the metadata too. Wired once inSeaRestTransport::execute_and_read, so every consumer (syncexecute, asyncsubmit/await_result, all ofmetadata_v0'slist_*) benefits.Pass-through when
manifest = Noneso paths without column info (test mocks, edge cases) don't change shape.Surfaced by
databricks-driver-test#303— the Thrift vs Kernel comparator surfaced:list_columns(catalog='nonexistent')flagging the type-code diffs (fixed by Initial import: Databricks ADBC Rust driver as databricks-sql-kernel #1).variant_columncases flagging type=string(kernel) vsvariant(Thrift). The Python connector (databricks-sql-python#793) was updated to readfield.metadata[b"databricks.type_name"]for the precise type — but the metadata was empty until this PR's refactor(adbc): quarantine ADBC surface and add v0 kernel skeleton #2 lands.Test plan
cargo +stable fmt --all -- --checkcleancargo clippy --all-targets -- -D warningscleancargo test --workspace— 382 lib + 15 metadata wiremock + all integration suites passManifestAugmentingReader(metadata-attached + pass-through paths)This pull request and its description were written by Claude Code.