krylosov-aa opened a new pull request, #2045:
URL: https://github.com/apache/cloudberry/pull/2045

   Fixes #2025
   
   ### What does this PR do?
   With `optimizer=off` and `gp_enable_multiphase_agg=on`, grouping by a 
constant can return a row when the input is empty. For example, `SELECT 
count(*) FROM t GROUP BY 'x'::text` returns one row with zero instead of no 
rows.
   
   The planner removes constant grouping keys, then treats the final 
aggregation step as if the query had no GROUP BY.
   
   This change checks the original GROUP BY clause when choosing the 
aggregation strategy. Empty input now returns no rows even when all grouping 
keys have been removed. It also fixes an assertion failure for constant GROUP 
BY without aggregate functions.
   
   ### Type of Change
   - [x] Bug fix (non-breaking change)
   
   ### Test Plan
   Added `gp_group_by_constant`. It fails before the fix and passes after it. 
The test covers both planners, single-phase and multi-phase aggregation, and 
parallel execution.
   
   Tested on Linux ARM64 with assertions enabled and three primary segments. 
`aggregates`, `gp_aggregates`, `gp_dqa`, `aggregate_with_groupingsets`, and 
`cbdb_parallel` also passed.
   
   
   ### Checklist
   - [x] Followed [contribution 
guide](https://cloudberry.apache.org/contribute/code)
   - [ ] Requested review from [cloudberry 
committers](https://github.com/orgs/apache/teams/cloudberry-committers)
   


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