This is an automated email from the ASF dual-hosted git repository.

gengliang pushed a commit to branch branch-3.5
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-3.5 by this push:
     new 999cd5fc05d [SPARK-44610][SQL] DeduplicateRelations should retain 
Alias metadata when creating a new instance
999cd5fc05d is described below

commit 999cd5fc05dbcd80d524a3d4537f5280458ddfbb
Author: Wenchen Fan <wenc...@databricks.com>
AuthorDate: Mon Jul 31 11:36:59 2023 -0700

    [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 #42242 from cloud-fan/mm.
    
    Authored-by: Wenchen Fan <wenc...@databricks.com>
    Signed-off-by: Gengliang Wang <gengli...@apache.org>
    (cherry picked from commit adf009d545d73cb583694a9c171357f289cf21dd)
    Signed-off-by: Gengliang Wang <gengli...@apache.org>
---
 .../org/apache/spark/sql/catalyst/analysis/DeduplicateRelations.scala   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/DeduplicateRelations.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/DeduplicateRelations.scala
index 1b43922de27..8d30712af42 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/DeduplicateRelations.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/DeduplicateRelations.scala
@@ -312,7 +312,7 @@ object DeduplicateRelations extends Rule[LogicalPlan] {
     // in the original project list, to avoid assertion failures when 
rewriting attributes
     // in transformUpWithNewOutput.
     val oldAliasToNewAlias = AttributeMap(expressions.collect {
-      case a: Alias => (a.toAttribute, Alias(a.child, a.name)())
+      case a: Alias => (a.toAttribute, a.newInstance())
     })
     expressions.map {
       case a: Alias => oldAliasToNewAlias(a.toAttribute)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to