SQL API: aggregates don't skip NULL values (COUNT(col) counts them, SUM and AVG throw NPE)
メンテナーはふだん 2 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 20/100
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Java
- スター
- 284
- フォーク
- 147
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 13
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/wayang のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 2 日以内に返信
-
JavaReservoirSampleOperator returns the whole input when the dataset size is unknown対応中かも @sasmith-14 が 7 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/wayang#884 · コメント 3 件 ·
メンテナーはふだん 2 日以内に返信
-
Record.compareTo() throws ClassCastException when comparing records対応中かも @harshitsingh070 が 69 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 2 日以内に返信
-
Unused parameter in function ProjectionDescriptor.createPojoJavaImplementation()対応中かも @AliRana30 が 77 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
apache/wayang#732 · コメント 3 件 ·
メンテナーはふだん 2 日以内に返信
-
DISCLAIMER and some "(incubating)" references are still around after graduation対応中かも @sasmith-14 が 1 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 66/100
apache/wayang#895 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
jenkins-infra/plugin-modernizer-tool#2070 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Event search answers 500 when calendars, attendees or organizers holds a null element再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンai-driven-qa bug Minor
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
linagora/twake-calendar-side-service#1615 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
eclipse-tradista/tradista#371 ·
メンテナーはふだん 1 日以内に返信
-
critical
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
mars-sim/mars-sim#2199 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
projeto-ong-amar/projeto-ong-amar-backend#26 ·
メンテナーはふだん 1 日以内に返信