mingmwang commented on code in PR #4866:
URL: https://github.com/apache/arrow-datafusion/pull/4866#discussion_r1070927024
##########
datafusion/optimizer/src/rewrite_disjunctive_predicate.rs:
##########
@@ -152,13 +152,48 @@ impl OptimizerRule for RewriteDisjunctivePredicate {
}
}
-#[derive(Clone, PartialEq, Debug)]
+#[derive(Clone, Debug)]
enum Predicate {
And { args: Vec<Predicate> },
Or { args: Vec<Predicate> },
Other { expr: Box<Expr> },
}
+impl PartialEq<Predicate> for Predicate {
+ fn eq(&self, other: &Predicate) -> bool {
+ match (self, other) {
+ // For BinaryExpr, A = B should be the same as B = A
+ // when extract A = B in expr like (A = B and C > D) OR (B = A and
C = E).
+ (Predicate::Other { expr: l }, Predicate::Other { expr: r }) => {
+ match (l.as_ref(), r.as_ref()) {
+ (
+ Expr::BinaryExpr(BinaryExpr {
+ left: ll,
+ op: l_op,
+ right: lr,
+ }),
+ Expr::BinaryExpr(BinaryExpr {
+ left: rl,
+ op: r_op,
+ right: rr,
+ }),
+ ) => {
+ l_op == r_op && ((ll == rl && lr == rr) || (ll == rr
&& lr == rl))
+ }
+ _ => false,
Review Comment:
Should we allow '`A < B`' **eq** '`B > A`' ?
--
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]