[Bug] Wrong results: GROUP BY a constant expression returns one row for empty input
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C
- Estrellas
- 1.4k
- Forks
- 248
- Merge medio
- 4 d 10 h
- PR fusionados (30 d)
- 40
Preparar el entorno
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/cloudberry
-
type: Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
apache/cloudberry#1885 · 2 reacciones ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
apache/cloudberry#1825 ·
Los mantenedores suelen responder en 1 día
-
type: Bug
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
apache/cloudberry#2048 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
type: Bug
Dificultad 4/5 3-5 días Aptitud para principiantes 40/100
apache/cloudberry#2047 ·
Los mantenedores suelen responder en 1 día
-
type: Bug
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
apache/cloudberry#2046 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de apache/cloudberry
Issues similares
-
area:lint-tooling bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
InauguralSystems/EigenScript#1340 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: chunk_span_bounds and _validated_chunk_spans reject Pydantic models ChunkSpan and AudioFileAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
BasedHardware/omi#19047 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
obsproject/obs-studio#13936 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
[meshoptimizer] update to 1.3Abiertocategory:port-update
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día