Skip to content

[VL] Allow casting NULL constants to complex types - #12950

Merged
zml1206 merged 1 commit into
apache:mainfrom
kevinwilfong:cast_null_complex
Sep 2, 2026
Merged

[VL] Allow casting NULL constants to complex types#12950
zml1206 merged 1 commit into
apache:mainfrom
kevinwilfong:cast_null_complex

Conversation

@kevinwilfong

Copy link
Copy Markdown
Collaborator

What changes are proposed in this pull request?

Gluten currently does not allow casting NULL constants to complex types, it fails during plan validation. This is an easy case to miss as Spark will typically constant fold it directly to a NULL constant. However, when the right side of a left outer join is empty at runtime AQE will replace the join with a project that casts NULLs to the types of the columns on the right side of the join. Since this happens after constant folding we see it in the plan and it causes Gluten to fallback to vanilla Spark.

Velox already supports this trivially, so all that's needed is a case in isAllowedCast to allow it.

How was this patch tested?

Added unit tests in Substrait2VeloxPlanValidatorTest to ensure casting NULL to ROW, ARRAY, and MAP types is allowed.

Added an end to end test in MiscOperatorSuite that demonstrates how the issue arises in a Spark plan.

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

co-authored using Claude Opus 5

@github-actions github-actions Bot added the VELOX label Sep 1, 2026
@github-actions github-actions Bot added the CORE works for Gluten Core label Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@kevinwilfong

Copy link
Copy Markdown
Collaborator Author

Failure in Velox Backend (x86) / spark-test-spark34 (3) looks to be flaky (it succeeded on the previous revision)

@kevinwilfong
kevinwilfong requested a review from zml1206 September 1, 2026 23:21

@zml1206 zml1206 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.

LGTM, thanks

@philo-he philo-he left a comment

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.

Thanks.

@zml1206
zml1206 merged commit f7f5f04 into apache:main Sep 2, 2026
101 of 102 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CORE works for Gluten Core VELOX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants