cetra3 commented on code in PR #27319:
URL: https://github.com/apache/datafusion/pull/27319#discussion_r4673882177
##########
datafusion/physical-expr/src/equivalence/class.rs:
##########
@@ -673,7 +685,25 @@ impl EquivalenceGroup {
return Some(Arc::clone(target));
}
}
- None
+ // Members of a class are equal on every row, so a projectable member
+ // stands in for `expr`.
+ let group = equivalents?;
+ if let Some(known) = tried.get(expr) {
+ return known.clone();
+ }
+ // Until `expr` has a result, `None` stops cycles such as `x = f(y)`,
+ // `y = g(x)`. The stored result then serves later uses of `expr`, such
+ // as the second `x` in `x * x`.
+ tried.insert(Arc::clone(expr), None);
+ let projected = group.get_equivalence_class(expr).and_then(|cls| {
+ cls.iter()
+ .filter(|member| *member != expr)
+ .find_map(|member| {
+ Self::project_expr_indirect(aug_mapping, member,
equivalents, tried)
+ })
+ });
+ tried.insert(Arc::clone(expr), projected.clone());
+ projected
Review Comment:
Thanks, applied your class-keyed `tried` in 7a6ada6d24. The PR tests, the
full slt suite and clippy pass. I also updated the description: the
literal-skip bullet is gone and the testing section lists every slt case and
unit test.
--
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]