Skip to content

[SQL] Bind nested Dataset projections to the serializer output schema - #59996

Draft
sunchao wants to merge 1 commit into
apache:masterfrom
sunchao:codex/fix-dataset-serializer-field-binding
Draft

sunchao wants to merge 1 commit into
apache:masterfrom
sunchao:codex/fix-dataset-serializer-field-binding

Conversation

@sunchao

@sunchao sunchao commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

Resolve references to serializer outputs by expression ID before pruning their nested fields. When rebuilding field accesses, use the schema that the serializer actually emits. Preserve the spelling of output columns requested by the query.

Why are the changes needed?

A case-insensitive reference can cause an array index exception during optimization. A serializer can also retain its original struct layout even when a narrower one was requested. In that case a projection can read a sibling of the requested field. For example, the constant-key Dataset query in the regression test returns map-a for a request for map-b.

This correctness fix was identified in the review of SPARK-60766 and can be backported independently.

Does this PR introduce any user-facing change?

Yes. Affected typed Dataset projections return the requested fields and preserve their output column names.

How was this patch tested?

Added two constant-selector regressions to DatasetOptimizationSuite covering the array error, output naming and the incorrect Map value. All 11 tests passed against Spark master’s 5.0.0-SNAPSHOT CI build with the standalone patch. On the unmodified parent, the other nine passed and the two new tests reproduced the wrong Map value and the array index exception. Changed-file ScalaStyle and git diff --check passed.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: OpenAI Codex (GPT-6)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant