Skip to content

Commit adf009d

Browse files
cloud-fangengliangwang
authored andcommitted
[SPARK-44610][SQL] DeduplicateRelations should retain Alias metadata when creating a new instance
### What changes were proposed in this pull request? This fixes a small but obvious mistake in the rule `DeduplicateRelations`. When creating a new instance of an existing Alias, we should only make it have a new exprId, and retain everything else, including metadata. ### Why are the changes needed? To fix a potential bug. I can't found any end-to-end query that is affected by this bug, but it's wrong to lose the metadata. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? existing tests Closes apache#42242 from cloud-fan/mm. Authored-by: Wenchen Fan <[email protected]> Signed-off-by: Gengliang Wang <[email protected]>
1 parent 1380a3d commit adf009d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/DeduplicateRelations.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ object DeduplicateRelations extends Rule[LogicalPlan] {
429429
// in the original project list, to avoid assertion failures when rewriting attributes
430430
// in transformUpWithNewOutput.
431431
val oldAliasToNewAlias = AttributeMap(expressions.collect {
432-
case a: Alias => (a.toAttribute, Alias(a.child, a.name)())
432+
case a: Alias => (a.toAttribute, a.newInstance())
433433
})
434434
expressions.map {
435435
case a: Alias => oldAliasToNewAlias(a.toAttribute)

0 commit comments

Comments
 (0)