File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -81,19 +81,18 @@ abstract class QueryPlan[PlanType <: QueryPlan[PlanType]] extends TreeNode[PlanT
8181    //  because then both `QueryPlan.inferAdditionalConstraints` and
8282    //  `UnaryNode.getAliasedConstraints` applies and may produce a non-converging set of
8383    //  constraints.
84-     //  For more details, infer https://issues.apache.org/jira/browse/SPARK-17733
85-     val  aliasMap  =  AttributeMap ((expressions ++  children.flatMap(_.expressions)).collect {
86-       case  a : Alias  =>  (a.toAttribute, a.child)
87-     })
84+     //  For more details, refer to https://issues.apache.org/jira/browse/SPARK-17733
85+     val  aliasSet  =  AttributeSet ((expressions ++  children.flatMap(_.expressions))
86+       .filter(_.isInstanceOf [Alias ]))
8887
8988    var  inferredConstraints  =  Set .empty[Expression ]
9089    constraints.foreach {
9190      case  eq @  EqualTo (l : Attribute , r : Attribute ) => 
9291        inferredConstraints ++=  (constraints -  eq).map(_ transform {
93-           case  a : Attribute  if  a.semanticEquals(l) &&  ! aliasMap .contains(r) =>  r
92+           case  a : Attribute  if  a.semanticEquals(l) &&  ! aliasSet .contains(r) =>  r
9493        })
9594        inferredConstraints ++=  (constraints -  eq).map(_ transform {
96-           case  a : Attribute  if  a.semanticEquals(r) &&  ! aliasMap .contains(l) =>  l
95+           case  a : Attribute  if  a.semanticEquals(r) &&  ! aliasSet .contains(l) =>  l
9796        })
9897      case  _ =>  //  No inference
9998    }
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments