[SPARK-59278][SQL] Fix CHAR comparison rewrite edge cases - #58585
Closed
srielau wants to merge 2 commits into
Closed
[SPARK-59278][SQL] Fix CHAR comparison rewrite edge cases#58585srielau wants to merge 2 commits into
srielau wants to merge 2 commits into
Conversation
Contributor
Author
|
Closing as a duplicate of #58553, which was opened first and already has committer approval. That PR fixes the same IN NULL-order and nested-struct padding bugs, and also addresses the redundant |
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 were proposed in this pull request?
Fix two CHAR comparison padding edge cases:
INlist expression in its original position while computing padding lengths, includingNULLentries.CAST(attribute AS STRING)nodes used to coerce untypedNULL, without treating user-specified casts as CHAR comparisons.JIRA: https://issues.apache.org/jira/browse/SPARK-59278
Why are the changes needed?
The previous
INrewrite partitioned null values away from non-null values and then zipped the original expression list with only the non-null lengths. IfNULLpreceded a matching literal, the matching literal could be dropped and a true result became null.Nested struct padding also overwrote its
needPaddingstate for each field. Padding required by an earlier field was therefore lost when a later field needed no rewrite. Activating that rewrite additionally required preserving a null parent struct rather than rebuilding it as a non-null struct of null fields.Does this PR introduce any user-facing change?
Yes. CHAR comparisons now preserve SQL three-valued
IN/NOT INsemantics whenNULLprecedes a matching literal, and nested struct comparisons apply all required CHAR padding while preserving parent nulls.How was this patch tested?
Added regression tests covering:
INandNOT INwithNULLbefore and between matching and non-matching literals.CAST(... AS STRING).Ran:
All selected tests and Scala style checks passed.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor Auto