[VL] Allow casting NULL constants to complex types - #12950
Merged
Conversation
kevinwilfong
force-pushed
the
cast_null_complex
branch
from
September 1, 2026 20:18
f38345d to
43ca427
Compare
|
Run Gluten Clickhouse CI on x86 |
Collaborator
Author
|
Failure in Velox Backend (x86) / spark-test-spark34 (3) looks to be flaky (it succeeded on the previous revision) |
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.
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