Repository navigation
fix(reader): source result column names from SEA manifest, not Arrow payload - #115
Merged
Merged
Conversation
…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>
sreekanth-db
enabled auto-merge
June 3, 2026 09:31
sreekanth-db
disabled auto-merge
June 4, 2026 12:58
This branch was previously deployed
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.
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'sColumnInfo.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 sameSELECT *returnedcol_0…col_Nwhen 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 overlaysColumnInfo.nameonto each Arrow field by position (unconditional), in addition to attaching the existingdatabricks.*type metadata.create_readerwraps every reader (CloudFetch, single-inline, multi-chunk inline-streaming) inResultPostProcessor, which calls this helper — so the fix applies uniformly across all data-bearing flows.ResultPostProcessoralready rebuilds eachRecordBatchonto 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 existingArrayRefs (Arc clone, no data copy) and changes only field names — column count and data types are untouched.ColumnInfo(position out of range) keep their original Arrow name.col_by_poskeyed onColumnInfo.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 (Arrowcol_Nvs 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 --checkclean ·cargo clippy --all-targets -- -D warningsclean · fullcargo test(lib + all integration binaries) green.Live (against a real warehouse, via the same harness across delivery paths):
SELECT 1 AS nnSELECT 1 AS test_int, 'abc' AS test_stringtest_int,test_stringSELECT *LIMIT 1id … struct_with_struct_column(28)SELECT *LIMIT 10id … struct_with_struct_column(28)SELECT *LIMIT 30000id … struct_with_struct_column(28)SELECT * WHERE 1=0id … struct_with_struct_column(28)Inline, CloudFetch, and empty all now agree on the real names;
SELECT 1and 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 identicalcreate_reader → ResultPostProcessor → augment_schema_with_manifestpath and its provider tests remain green.