SQL API: aggregates don't skip NULL values (COUNT(col) counts them, SUM and AVG throw NPE)
Los mantenedores suelen responder en 2 días
@AarushShetty346 ya está trabajando en esto.
Desde el 18/11/2026.
- #893 de @AarushShetty346 — abierto
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 20/100
Línea de trabajo
Start with AggregateAddCols.java, AggregateFunction.java, and AggregateGetResult.java at the linked lines; trace how NULL values are handled through aggregation and how AVG gets its count. Reproduce the listed queries on the Java platform, including a GROUP BY case, and check the behavior on Spark. Done means COUNT(col), SUM, and AVG match the expected results while COUNT(*) still counts every row.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Aggregates in the SQL API treat NULL as a value. COUNT(col) counts NULL rows, and SUM / AVG throw a NullPointerException when a column has a NULL.
In SQL, every aggregate except COUNT(*) ignores NULL values. There are three spots where this goes wrong:
AggregateAddCols.java:53sets every COUNT column to1, soCOUNT(col)is always the same asCOUNT(*).AggregateFunction.java:118-124picks the type from whichever side isn't null, then still passes the null to the function. For example,Integer::sumis applied to(1, null)and fails on unboxing.AggregateGetResult.java:55-56divides the AVG sum by the row count, not by the number of non-null values. AVG would therefore be wrong even without the NPE.
To reproduce
col1:int,col2:string
1;a
;b
3;c
On the Java platform:
| query | result | expected |
|---|---|---|
SELECT COUNT(*) FROM fs.exampleNull |
3 | 3 |
SELECT COUNT(col1) FROM fs.exampleNull |
3 | 2 |
SELECT SUM(col1) FROM fs.exampleNull |
NPE | 4 |
SELECT AVG(col1) FROM fs.exampleNull |
NPE | 2.0 |
java.lang.NullPointerException
at org.apache.wayang.api.sql.calcite.converter.functions.AggregateFunction.castAndMap(AggregateFunction.java:127)
at org.apache.wayang.api.sql.calcite.converter.functions.AggregateFunction.apply(AggregateFunction.java:58)
The same thing happens with GROUP BY when a group has both NULL and non-NULL values. It fails in JavaReduceBy, and in Spark too.
Tested on main at 713faa7. I have a fix with tests and will open a PR for it.
- Lenguaje dominante
- Java
- Estrellas
- 284
- Forks
- 147
- Merge medio
- 2 d 13 h
- PR fusionados (30 d)
- 13
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
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/wayang
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 2 días
-
JavaReservoirSampleOperator returns the whole input when the dataset size is unknownPosiblemente ocupada @sasmith-14 la tomó hace 7 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
apache/wayang#884 · 3 comentarios ·
Los mantenedores suelen responder en 2 días
-
Record.compareTo() throws ClassCastException when comparing recordsPosiblemente ocupada @harshitsingh070 la tomó hace 69 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 2 días
-
Unused parameter in function ProjectionDescriptor.createPojoJavaImplementation()Posiblemente ocupada @AliRana30 la tomó hace 77 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
apache/wayang#732 · 3 comentarios ·
Los mantenedores suelen responder en 2 días
-
DISCLAIMER and some "(incubating)" references are still around after graduationPosiblemente ocupada @sasmith-14 la tomó hace 1 día. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 66/100
apache/wayang#895 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 2 días
Todos los issues de apache/wayang
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
jenkins-infra/plugin-modernizer-tool#2070 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Event search answers 500 when calendars, attendees or organizers holds a null elementQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertoai-driven-qa bug Minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
linagora/twake-calendar-side-service#1615 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
eclipse-tradista/tradista#371 ·
Los mantenedores suelen responder en 1 día
-
Failed to start Rescue missionAbiertocritical
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
mars-sim/mars-sim#2199 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
[BUG-02] Endpoints /assistente/relatorio/*/preview retornam 404 ("Ver na tela" dos relatórios)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
projeto-ong-amar/projeto-ong-amar-backend#26 ·
Los mantenedores suelen responder en 1 día