Apache Cloudberry version
main branch
What happened
When ORCA translates a GROUP BY ROLLUP(...) / CUBE(...) / GROUPING SETS () query, columns can be silently NULL-ed out in the wrong grouping levels, producing incorrect query
results — no error, no crash, just wrong output.
What you think should happen instead
Reproduction
-- Apache Cloudberry / GPDB, ORCA enabled (default)
SET optimizer = on;
SELECT generate_series(1, a) g, a+b ab
FROM (VALUES (1,1),(2,2)) t(a,b)
GROUP BY ROLLUP(a, ab)
ORDER BY 1, 2;
Actual (buggy) result with ORCA
g | ab
---+----
(0 rows)
Expected result (matches PostgreSQL planner, SET optimizer = off)
g | ab
---+----
1 | 2
1 | 4
1 |
1 |
2 | 4
2 |
(6 rows)
### How to reproduce
RT
### Operating System
centos9
### Anything else
_No response_
### Are you willing to submit PR?
- [x] Yes, I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/cloudberry/blob/main/CODE_OF_CONDUCT.md).
Apache Cloudberry version
main branch
What happened
When ORCA translates a
GROUP BY ROLLUP(...)/CUBE(...)/GROUPING SETS ()query, columns can be silently NULL-ed out in the wrong grouping levels, producing incorrect queryresults — no error, no crash, just wrong output.
What you think should happen instead
Reproduction