Skip to content

[GLUTEN-13823][CORE] Avoid eager union output resolution during AQE canonicalization - #13824

Open
wForget wants to merge 3 commits into
apache:mainfrom
wForget:GLUTEN-13823
Open

wForget wants to merge 3 commits into
apache:mainfrom
wForget:GLUTEN-13823

Conversation

@wForget

@wForget wForget commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

What changes are proposed in this pull request?

Fixes #13823.

During AQE stage creation, Spark canonicalizes the physical plan and copies ColumnarUnionExec. When UNION ALL implicitly casts a map with non-nullable values, the copied child can contain an unresolved output attribute. The union constructor evaluates output to pass the merged schema to WholeStageTransformer, which reads the attribute's nullability and throws Invalid call to nullable on unresolved object.

Check needOutputSchemaForPlan() before evaluating output. Velox skips the unnecessary schema computation, while ClickHouse continues to receive the merged schema it uses to align union branches.

How was this patch tested?

Added unit tests

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

Generated-by: OpenAI Codex (GPT-6)

@github-actions github-actions Bot added the CORE works for Gluten Core label Nov 27, 2026
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@apache apache deleted a comment from github-actions Bot Nov 27, 2026
@apache apache deleted a comment from github-actions Bot Nov 27, 2026
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@wForget
wForget marked this pull request as ready for review November 27, 2026 09:36
Copilot AI balanced review requested due to automatic review settings November 27, 2026 09:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

case w: WholeStageTransformer =>
// AQE can copy this union with unresolved attributes during canonicalization.
// Only compute its output for backends that require the merged schema.
case w: WholeStageTransformer if BackendsApiManager.getSettings.needOutputSchemaForPlan() =>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This still evaluates output on canonicalized copies for ClickHouse, where needOutputSchemaForPlan() is true (CHBackend.scala:381), and the new test fails there with the original error (ClickHouse CI build 22820, Spark35 UT: - Gluten - rebalance a union that implicitly casts non-nullable map values *** FAILED *** ... UnresolvedException: Invalid call to nullable on unresolved object). Canonicalized children can be unresolved on any backend; could the constructor skip the schema push when the child is canonicalized, or move setOutputSchemaForPlan out of the constructor, instead of keying on the backend? The union's own canonicalized flag is only set after doCanonicalize() returns, so the check would have to be on the child; a canonicalized WholeStageTransformer is never transformed (WholeStageTransformer.scala:102), so it doesn't need the schema.

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

CORE works for Gluten Core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[VL] Fails to canonicalize ColumnarUnionExec when UNION ALL requires an implicit map cast

3 participants