Lordworms commented on PR #11897:
URL: https://github.com/apache/datafusion/pull/11897#issuecomment-2283017366

   > I think the way to handle `false` for group by and having expr is rewrite 
the expression in optimizer, probably SimplifyExpr pattern matching. We rewrite 
it to expr that returns `empty row` if we found the expression in group by or 
having is evaluated to false.
   > 
   > btw, the issue is not strictly tied to group by + having
   > 
   > We should also return empty rows for these queries `select avg(a) from t 
group by false` `select avg(a) from t group by true` `select avg(a) from t 
having false` -- empty rows
   > 
   > `select avg(a) from t having true` -- null
   
   I don't think that's enough, the key here is we need to return empty set for 
those queries, but if group by is global and the table is not empty, we could 
not rewrite like this, the only way for us to know whether return an empty set 
or a null is in execution.


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