alamb commented on code in PR #11197:
URL: https://github.com/apache/datafusion/pull/11197#discussion_r1662520975
##########
datafusion/optimizer/src/common_subexpr_eliminate.rs:
##########
@@ -1012,19 +1013,22 @@ impl TreeNodeRewriter for CommonSubexprRewriter<'_, '_>
{
self.alias_counter += 1;
}
- // The `CommonSubexprRewriter` relies on `ExprIdentifierVisitor` to
generate
- // the `id_array`, which records the expr's identifier used to rewrite
expr. So if we
+ // The `CommonSubexprRewriter` relies on `ExprIdentifierVisitor` to
generate the
+ // `id_array`, which records the expr's identifier used to rewrite
expr. So if we
// skip an expr in `ExprIdentifierVisitor`, we should skip it here,
too.
- if expr.short_circuits() {
- return Ok(Transformed::new(expr, false, TreeNodeRecursion::Jump));
- }
+ let is_tree = expr.short_circuits();
+ let tnr = if is_tree {
+ TreeNodeRecursion::Jump
Review Comment:
I don't understand the meaning of `is_tree` here.
Maybe we could add a comment explaining that `Jump` will skip children but
continue with siblings
##########
datafusion/optimizer/src/common_subexpr_eliminate.rs:
##########
@@ -1799,4 +1803,34 @@ mod test {
assert!(result.len() == 1);
Ok(())
}
+
+ #[test]
+ fn test_short_circuits() -> Result<()> {
+ let table_scan = test_table_scan()?;
+
+ let extracted_short_circuit =
col("a").eq(lit(0)).or(col("b").eq(lit(0)));
+ let not_extracted_short_circuit_leg = (col("a") + col("b")).eq(lit(0));
+ let plan = LogicalPlanBuilder::from(table_scan.clone())
Review Comment:
I think this test covers the negative case too.
--
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]