0xamlab commented on issue #26505:
URL: https://github.com/apache/datafusion/issues/26505#issuecomment-6317223500

   Reproduced on main (6c1727fc, cli v55.1.0): v=10 for a=1 where PostgreSQL 17 
returns NULL, and EXPLAIN shows no HAVING filter. Root cause: 
PullUpCorrelatedExpr pulls a HAVING that is true on empty input out of the 
subquery and removes the Filter (datafusion/optimizer/src/decorrelate.rs:435), 
intending to re-apply it via the count-bug compensation CASE. But build_join 
skips that compensation for aggregates whose empty-input value is NULL 
(sum/max/min) at datafusion/optimizer/src/scalar_subquery_to_join.rs:407, so 
the HAVING is never re-applied. count(*) escapes because its empty-input value 
0 is non-NULL, hence HAVING count(*) = 0 still returns NULL, 0.


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