morristai commented on code in PR #26634:
URL: https://github.com/apache/datafusion/pull/26634#discussion_r4583506136


##########
datafusion/physical-optimizer/src/projection_pushdown.rs:
##########
@@ -302,6 +306,10 @@ fn minimize_join_filter(
 /// this is never the case, no subexpressions of the filter can be pushed 
down. If there is a
 /// subexpression that can be computed using only one side of the join, the 
entire subexpression is
 /// pushed down to the join side.
+///
+/// The top-level conjuncts of the filter are searched in full. Below them, 
children that an

Review Comment:
   You're right, this looks like an AI slop.
   
   quick example:
   ```sql
   CREATE TABLE l(s VARCHAR) AS VALUES ('1'), ('x');
   CREATE TABLE r(v INT) AS VALUES (0), (5);
   
   SELECT l.s, r.v FROM l JOIN r
   ON CASE WHEN r.v > 100 THEN CAST(l.s AS INT) ELSE 0 END > 1;
   ```
   
   Since none of the columns in `r.v` are greater than 100, `CAST(l.s AS INT)` 
should not be executed, and the query should return 0 columns.
   
   However, in the main function, `CAST(l.s AS INT)` only uses the left-hand 
column, so it was moved to `ProjectionExec` below the join. That projection 
will execute on every column of `l`, failing when it encounters an `'x'`.
   
   (PS. I changed it as you suggested: the rewriter now stops when it 
encounters an expression that involves a short-circuit and doesn't proceed. In 
the example above, the entire `CASE` will remain in the join filter.)



-- 
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]

Reply via email to