acking-you commented on issue #11212: URL: https://github.com/apache/datafusion/issues/11212#issuecomment-2205337547
> > What I'm trying to get at is that there's currently unnecessary computation happening within `BinaryExpr` (perhaps in many cases, just calculating the `left` side would be sufficient to determine the result). > > I would be surprise if there is any, could you provide the example that shows optimizer failed to do what you expect? > > Here is the optimize rule that skip the right hand side if left is false > > https://github.com/apache/datafusion/blob/3421b52605b00cd2e5a6498ea210cce196a19496/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs#L848-L853 What I'm trying to describe is probably something like this. ```sql SELECT customer_id, first_name, last_name, email, total_purchases FROM customers WHERE some_udf(first_name) -- if this condition is mostly false at runtime. AND ( (total_purchases > 1000 AND EXTRACT(YEAR FROM registration_date) > 2018) OR (LOWER(email) LIKE '%@gmail.com' AND loyalty_points > 500) OR ( LENGTH(first_name) + LENGTH(last_name) > 15 AND SUBSTR(last_name, 1, 1) IN ('M', 'N', 'O', 'P') AND DATE_PART('month', last_purchase_date) BETWEEN 6 AND 8 ) ) AND ( customer_id % 3 = 0 OR EXISTS ( SELECT 1 FROM orders WHERE orders.customer_id = customers.customer_id AND orders.order_status = 'Completed' AND orders.order_total > 250 ) ); ``` -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org