peter-toth commented on code in PR #37851:
URL: https://github.com/apache/spark/pull/37851#discussion_r968767960
##########
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:
I think this approach can be refectored further and we can move all logic
from `preCanonicalized` to `canonicalized`, just we need to override
commutative operators's `canonicalized` to call
`Canonicalize.reorderCommutativeOperators`:
https://github.com/apache/spark/pull/37851/commits/726f7f0abbd8110256973f2a29b9d60bb3cc51ce
--
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]