abp002 commented on code in PR #26967:
URL: https://github.com/apache/datafusion/pull/26967#discussion_r4573791625
##########
datafusion/physical-expr/src/equivalence/class.rs:
##########
@@ -213,6 +213,35 @@ impl EquivalenceClass {
}
}
self.exprs.insert(expr);
+ self.promote_sub_expressions();
+ }
+
+ /// Makes sure the canonical expression does not contain another expression
+ /// of this class. Otherwise, with `a + b` as the canonical expression of a
+ /// class that also holds `a`, normalization would replace the `a` inside
+ /// `a + b` and turn `a + b` into `(a + b) + b`.
+ fn promote_sub_expressions(&mut self) {
+ // Each promoted expression is inside the previous canonical
+ // expression, so there are at most as many rounds as members.
+ for _ in 0..self.exprs.len() {
Review Comment:
Added, thanks!
--
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]