gengliangwang commented on a change in pull request #30894:
URL: https://github.com/apache/spark/pull/30894#discussion_r551317823



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/LogicalPlan.scala
##########
@@ -175,20 +175,57 @@ abstract class UnaryNode extends LogicalPlan {
    */
   protected def getAllValidConstraints(projectList: Seq[NamedExpression]): 
ExpressionSet = {
     var allConstraints = child.constraints
-    projectList.foreach {
-      case a @ Alias(l: Literal, _) =>
-        allConstraints += EqualNullSafe(a.toAttribute, l)
-      case a @ Alias(e, _) =>
-        // For every alias in `projectList`, replace the reference in 
constraints by its attribute.
-        allConstraints ++= allConstraints.map(_ transform {
-          case expr: Expression if expr.semanticEquals(e) =>
-            a.toAttribute
+
+    // For each expression collect its aliases
+    val aliasMap = projectList.collect{
+      case alias @ Alias(expr, _) if !expr.foldable => (expr.canonicalized, 
alias)

Review comment:
       We need to filter the non-deterministic expressions here.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to