peter-toth commented on code in PR #37851:
URL: https://github.com/apache/spark/pull/37851#discussion_r968490045


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Canonicalize.scala:
##########
@@ -65,6 +78,15 @@ object Canonicalize {
       val newChildren = orderCommutative(l, { case Least(children) => children 
})
       Least(newChildren)
 
-    case _ => e.withNewChildren(e.children.map(reorderCommutativeOperators))
+    case bc: EqualTo => orderBinaryComparison(bc, EqualTo)
+    case bc: EqualNullSafe => orderBinaryComparison(bc, EqualNullSafe)
+
+    case bc: GreaterThan => orderBinaryComparison(bc, LessThan)
+    case bc: LessThan => orderBinaryComparison(bc, GreaterThan)
+
+    case bc: GreaterThanOrEqual => orderBinaryComparison(bc, LessThanOrEqual)
+    case bc: LessThanOrEqual => orderBinaryComparison(bc, GreaterThanOrEqual)
+
+    case _ => 
e.mapChildren(preCanonicalizeAndReorderOperators).preCanonicalized

Review Comment:
   We would say that we canonicalize and reorder the node's children first and 
then pre-canonicalize the node.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Canonicalize.scala:
##########
@@ -65,6 +78,15 @@ object Canonicalize {
       val newChildren = orderCommutative(l, { case Least(children) => children 
})
       Least(newChildren)
 
-    case _ => e.withNewChildren(e.children.map(reorderCommutativeOperators))
+    case bc: EqualTo => orderBinaryComparison(bc, EqualTo)
+    case bc: EqualNullSafe => orderBinaryComparison(bc, EqualNullSafe)
+
+    case bc: GreaterThan => orderBinaryComparison(bc, LessThan)
+    case bc: LessThan => orderBinaryComparison(bc, GreaterThan)
+
+    case bc: GreaterThanOrEqual => orderBinaryComparison(bc, LessThanOrEqual)
+    case bc: LessThanOrEqual => orderBinaryComparison(bc, GreaterThanOrEqual)
+
+    case _ => 
e.mapChildren(preCanonicalizeAndReorderOperators).preCanonicalized

Review Comment:
   We would say that we pre-canonicalize and reorder the node's children first 
and then pre-canonicalize the node.



-- 
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.

To unsubscribe, e-mail: [email protected]

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