Skip to content

fix(metadata + reader): match Thrift wire types and wire manifest augmenter - #34

Merged
vikrantpuppala merged 1 commit into
mainfrom
fix/list-columns-thrift-types
May 19, 2026
Merged

vikrantpuppala merged 1 commit into
mainfrom
fix/list-columns-thrift-types

Conversation

@vikrantpuppala

@vikrantpuppala vikrantpuppala commented May 19, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Two related fixes:

1. Match Thrift's wire types for BUFFER_LENGTH and SOURCE_DATA_TYPE

Column Was Now Thrift wire JDBC spec
BUFFER_LENGTH Int32 Int8 TINYINT Types.INTEGER
SOURCE_DATA_TYPE Int32 Int16 SMALLINT Types.SMALLINT

JDBC spec says Types.INTEGER / Types.SMALLINT. Thrift's GetColumns RPC happens to ship BUFFER_LENGTH as TINYINT (HiveServer2-era wire quirk) and SOURCE_DATA_TYPE as SMALLINT. 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 ManifestAugmentingReader into execute_and_read

augment_schema_with_manifest was added on ResultReaderAdapter to attach Databricks-specific per-column metadata from the SEA ResultManifest (databricks.type_name, databricks.type_text, precision, scale, interval kind). But the augmenter was only reachable through ResultReaderAdapter (Arrow-FFI shape); the live execute path uses the kernel's own ResultReader trait directly, so the metadata was never actually present on ResultStream::schema() consumers.

Introduce ManifestAugmentingReader — a thin wrapper implementing the kernel's ResultReader trait, exposing the augmented schema via schema(), and re-projecting each emitted RecordBatch onto that schema so batch.schema() carries the metadata too. Wired once in SeaRestTransport::execute_and_read, so every consumer (sync execute, async submit/await_result, all of metadata_v0's list_*) benefits.

Pass-through when manifest = None so paths without column info (test mocks, edge cases) don't change shape.

Surfaced by

databricks-driver-test#303 — the Thrift vs Kernel comparator surfaced:

Test plan

  • cargo +stable fmt --all -- --check clean
  • cargo clippy --all-targets -- -D warnings clean
  • cargo test --workspace — 382 lib + 15 metadata wiremock + all integration suites pass
  • Two new unit tests for ManifestAugmentingReader (metadata-attached + pass-through paths)

This pull request and its description were written by Claude Code.

…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>
@vikrantpuppala
vikrantpuppala merged commit b8449b3 into main May 19, 2026
@vikrantpuppala vikrantpuppala changed the title fix(metadata): match Thrift wire types for BUFFER_LENGTH and SOURCE_DATA_TYPE fix(metadata + reader): match Thrift wire types and wire manifest augmenter May 19, 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