Skip to content

fix(reader): source result column names from SEA manifest, not Arrow payload - #115

Merged
sreekanth-db merged 2 commits into
mainfrom
fix/sea-column-names-from-manifest
Jun 4, 2026
Merged

sreekanth-db merged 2 commits into
mainfrom
fix/sea-column-names-from-manifest

Conversation

@sreekanth-db

Copy link
Copy Markdown
Contributor

Why

SEA returns positional placeholder column names (col_0, col_1, …) in the Arrow result payload by design — the authoritative column names live in the result manifest's ColumnInfo.name. The kernel was surfacing the Arrow placeholder names for row-bearing results, while the zero-row path (extract_schema_from_manifest) already reconstructed real names from the manifest. The consequence: the same SELECT * returned col_0…col_N when it had rows but the real names (id, varchar_column, …) when empty — an inconsistency between the data-bearing and zero-row paths.

THRIFT carries real names inline, so the THRIFT-vs-SEA comparator flags this divergence. Per the kernel-comparator triage, this is not a server bug (the positional names are the intended SEA contract) and the agreed resolution is a client-side fix in the kernel: source column names from manifest.schema.

What changed

ResultReaderAdapter::augment_schema_with_manifest (src/reader/mod.rs) now overlays ColumnInfo.name onto each Arrow field by position (unconditional), in addition to attaching the existing databricks.* type metadata.

  • This helper is the single funnel point: create_reader wraps every reader (CloudFetch, single-inline, multi-chunk inline-streaming) in ResultPostProcessor, which calls this helper — so the fix applies uniformly across all data-bearing flows.
  • ResultPostProcessor already rebuilds each RecordBatch onto the augmented schema whenever it differs from the inner schema, so the rename propagates to the batches consumers receive, not just the advertised schema. The rebuild reuses the existing ArrayRefs (Arc clone, no data copy) and changes only field names — column count and data types are untouched.
  • Fields with no matching ColumnInfo (position out of range) keep their original Arrow name.
  • The position-matching (col_by_pos keyed on ColumnInfo.position) is the pre-existing invariant already used for metadata attachment — no new matching logic is introduced.

This makes the row-bearing path agree with the already-correct zero-row path, and matches THRIFT's behavior.

How it was tested

Unit / integration (added):

  • reader::tests::test_augment_schema_overlays_manifest_names_over_positional — the mismatch fixture (Arrow col_N vs manifest real names) that the pre-existing augment tests couldn't catch (they used matching names).
  • reader::tests::test_augment_schema_keeps_arrow_name_when_no_manifest_column — out-of-range fields keep their Arrow name.
  • post_processor::tests::manifest_overlays_real_names_onto_positional_columns_and_batches — asserts both the advertised schema and the yielded batch carry the manifest names, with data preserved.

Suite: cargo fmt --all --check clean · cargo clippy --all-targets -- -D warnings clean · full cargo test (lib + all integration binaries) green.

Live (against a real warehouse, via the same harness across delivery paths):

Flow Reader Column names Rows
SELECT 1 AS n inline n 1
SELECT 1 AS test_int, 'abc' AS test_string inline test_int, test_string 1
SELECT * LIMIT 1 inline id … struct_with_struct_column (28) 1
SELECT * LIMIT 10 inline id … struct_with_struct_column (28) 10
SELECT * LIMIT 30000 CloudFetch id … struct_with_struct_column (28) 30000
SELECT * WHERE 1=0 empty id … struct_with_struct_column (28) 0

Inline, CloudFetch, and empty all now agree on the real names; SELECT 1 and aliased queries are unaffected (no regression). The multi-chunk inline-streaming flow couldn't be triggered live (the test warehouse never emits that disposition), but it routes through the identical create_reader → ResultPostProcessor → augment_schema_with_manifest path and its provider tests remain green.

…payload

SEA emits positional placeholder names (`col_0`, `col_1`, …) in the Arrow
result payload by design; the authoritative column names live in the
manifest's `ColumnInfo.name`. The kernel was surfacing the Arrow
placeholder names for row-bearing results, while the zero-row path
(`extract_schema_from_manifest`) already reconstructed real names from the
manifest — so the same `SELECT *` returned `col_N` with rows but real names
when empty. THRIFT carries real names inline, so the comparator flagged the
divergence.

`augment_schema_with_manifest` now overlays `ColumnInfo.name` onto each
field by position (unconditional), in addition to attaching the existing
`databricks.*` type metadata. Because `ResultPostProcessor` rebuilds each
batch onto the augmented schema whenever it differs from the inner schema,
the rename propagates to the batches consumers receive — not just the
advertised schema. Fields with no matching manifest column keep their
original Arrow name.

Decided client-side per the kernel-comparator triage (SEA contract item
#12).

Tests:
- reader::tests::test_augment_schema_overlays_manifest_names_over_positional
  — the mismatch fixture (Arrow `col_N` vs manifest real names) that the
  pre-existing augment tests couldn't catch (they used matching names).
- reader::tests::test_augment_schema_keeps_arrow_name_when_no_manifest_column
- post_processor::tests::manifest_overlays_real_names_onto_positional_columns_and_batches
  — asserts both the advertised schema and the yielded batch carry the
  manifest names, with data preserved.

Co-authored-by: Isaac
Signed-off-by: Sreekanth Vadigi <sreekanth.vadigi@databricks.com>

@vikrantpuppala vikrantpuppala left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thanks!

@sreekanth-db
sreekanth-db enabled auto-merge June 3, 2026 09:31
@sreekanth-db
sreekanth-db disabled auto-merge June 4, 2026 12:58
@sreekanth-db
sreekanth-db added this pull request to the merge queue Jun 4, 2026
Merged via the queue into main with commit 1cfb285 Jun 4, 2026
14 checks passed

This branch was previously deployed

1 inactive deployment
azure-prod — c4d77f02 Deployed Jun 3, 2026 by sreekanth-db via v0 TLS (mitmproxy) #63
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.

2 participants