[SPARK-51732][SQL] Apply rpad
on attributes with same ExprId
if they need to be deduplicated
#50527
+66
−4
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?
This PR fixes a case where
rpad
is not applied on attributes that have the sameExprId
even though those attributes should be deduplicated.Why are the changes needed?
For example, consider the following query:
In the above case,
ApplyCharTypePadding
will run for subquery wheret1.a
andt2.a
will reference the sameExprId
, therefore we won't applyrpad
. However, afterDeduplicateRelations
runs for outer query,t1.a
andt2.a
will get differentExprIds
and would therefore needrpad
. However, this doesn't happen becauseApplyCharTypePadding
for outer query does not recurse into the subquery.On the other hand, for a query:
ApplyCharTypePadding
will correctly addrpad
to botht1.a
andt2.a
because attributes will first be deduplicated.In particular, this fixes a code-path when
readSideCharPadding
is off andLEGACY_NO_CHAR_PADDING_IN_PREDICATE
is also falseDoes this PR introduce any user-facing change?
How was this patch tested?
Was this patch authored or co-authored using generative AI tooling?
No