HairstonE opened a new pull request, #22132:
URL: https://github.com/apache/datafusion/pull/22132

   ## Which issue does this PR close?
   
   Closes #11748
   
   ## Rationale for this change
   
   `EliminateGroupByConstant` strips constant expressions from GROUP BY. When 
it strips all of them, it converts a grouping aggregate into a global 
aggregate. A grouping aggregate returns 0 rows on empty input, a global 
aggregate returns 1. `GROUP BY false HAVING false` should return 0 rows. It was 
returning 1 row of NULL.
   
   Found the root cause by reading PR #11897.
   
   ## What changes are included in this PR?
   
   The guard now bails out whenever all GROUP BY expressions are constants, 
regardless of whether aggregate functions exist. One line change, plus updated 
tests.
   
   ## Are these changes tested?
   
   Yes. Sqllogictest reproducer for the original issue, updated unit test and 
optimizer SLT expectations.
   
   ## Are there any user-facing changes?
   Queries with all-constant GROUP BY may now return fewer (correct) rows.


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