SQL API: aggregates don't skip NULL values (COUNT(col) counts them, SUM and AVG throw NPE)
I maintainer di solito rispondono entro 2 giorni
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 20/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Java
- Stelle
- 284
- Fork
- 147
- Merge medio
- 2g 13h
- PR unite (30g)
- 13
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/wayang
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 2 giorni
-
JavaReservoirSampleOperator returns the whole input when the dataset size is unknownForse già presa @sasmith-14 l’ha presa 7 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
apache/wayang#884 · 3 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
Record.compareTo() throws ClassCastException when comparing recordsForse già presa @harshitsingh070 l’ha presa 69 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 2 giorni
-
Unused parameter in function ProjectionDescriptor.createPojoJavaImplementation()Forse già presa @AliRana30 l’ha presa 77 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
apache/wayang#732 · 3 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
DISCLAIMER and some "(incubating)" references are still around after graduationForse già presa @sasmith-14 l’ha presa 1 giorno fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 66/100
apache/wayang#895 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di apache/wayang
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
jenkins-infra/plugin-modernizer-tool#2070 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Event search answers 500 when calendars, attendees or organizers holds a null elementForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertaai-driven-qa bug Minor
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
linagora/twake-calendar-side-service#1615 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
eclipse-tradista/tradista#371 ·
I maintainer di solito rispondono entro 1 giorno
-
critical
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
mars-sim/mars-sim#2199 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG-02] Endpoints /assistente/relatorio/*/preview retornam 404 ("Ver na tela" dos relatórios)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
projeto-ong-amar/projeto-ong-amar-backend#26 ·
I maintainer di solito rispondono entro 1 giorno