[Bug] Wrong results: GROUP BY a constant expression returns one row for empty input
Maintainer thường phản hồi trong vòng 3 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
Start by reproducing the two queries with optimizer = off and inspecting the provided EXPLAIN output, then trace how the PostgreSQL planner handles constant GROUP BY keys and multiphase aggregation. Done means empty input produces zero rows in both cases, without regressing non-empty inputs or the GPORCA path.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Apache Cloudberry version
main branch
What happened
With the Postgres planner (optimizer = off), a query that groups by a constant expression returns one row when the input table is empty. A GROUP BY over zero input rows has zero groups, so the
correct answer is no rows.
GPORCA (optimizer = on) is not affected. Non-empty inputs are not affected — the extra row only appears when the input is empty.
What you think should happen instead
No response
How to reproduce
CREATE TABLE g(c0 boolean) DISTRIBUTED BY (c0); -- left EMPTY
SET optimizer = off;
SELECT count(*) FROM g GROUP BY 'x'::text;
-- count
-- -------
-- 0 <-- WRONG, expected 0 rows
SELECT 1 FROM g GROUP BY (0.25)::MONEY HAVING count(*) = 0;
-- ?column?
-- ----------
-- 1 <-- WRONG, expected 0 rows
Expected in both cases: (0 rows).
The plan shows the grouping key disappearing and the final aggregate becoming a plain Aggregate, which always emits one row:
EXPLAIN (VERBOSE, COSTS OFF) SELECT count(*) FROM g GROUP BY 'x'::text;
Finalize Aggregate
Output: count(*), 'x'::text
-> Gather Motion 3:1 (slice1; segments: 3)
Output: (PARTIAL count(*))
-> Partial GroupAggregate
Output: PARTIAL count(*)
-> Seq Scan on public.g
Workarounds
SET optimizer = on;(GPORCA), orSET gp_enable_multiphase_agg = off;
Operating System
any
Anything else
No response
Are you willing to submit PR?
- Yes, I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct.
- Ngôn ngữ chính
- C
- Star
- 1.4k
- Fork
- 262
- Merge trung bình
- 4 ngày 20 giờ
- Pull request đã merge (30 ngày)
- 57
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/cloudberry
-
[Bug] Expand fails to recognize user-defined tablespacesCó thể đã có người làm @nix-oss đã nhận 61 ngày trước. Đang mởtype: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
apache/cloudberry#1885 · 2 reaction ·
Maintainer thường phản hồi trong vòng 3 ngày
-
gpexpand first stage fails: 'SyncPackages' object has no attribute 'ret' (extension sync never runs; regression)Có thể đã có người làm @talmacschen-arch đã nhận 122 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
apache/cloudberry#1825 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Lance support: contrib/lance_fdw and the MCP server's Lance toolsCó thể đã có người làm @MisterRaindrop đã nhận 2 ngày trước. Đang mở
apache/cloudberry#2139 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
-
type: Bug
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 58/100
apache/cloudberry#2137 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
type: Proposal
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
apache/cloudberry#2136 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của apache/cloudberry
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
FujiNetWIFI/fujinet-firmware#2045 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
gbdev/homebrewhub-submit#20 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
OpenPrinting/cups#1772 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
snowballstem/snowball#311 ·