SQL API: ORDER BY throws NullPointerException when the sort column contains NULL
メンテナーはふだん 3 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
調査の方向性
Start with SortKeyExtractor.java at the comparison on line 50 and WayangSortVisitor.java at lines 60–61, which maps the sort direction. Trace how Calcite’s null direction reaches the comparator, then run the SQL API sorting tests with the provided CSV and queries. Done when ascending, descending, and explicit NULLS FIRST produce the expected row order without an exception.
索引モデルが issue の本文から書いたものです。
説明
ORDER BY in the SQL API fails with a NullPointerException as soon as the sort column has a NULL value.
The bug
SortKeyExtractor compares sort keys directly at SortKeyExtractor.java:50:
final int comparison = direction.isDescending() ? -thisField.compareTo(thatField) : thisField.compareTo(thatField);
An empty cell in a numeric CSV column is read as null, so thisField (or thatField) can be null here. The null direction of the collation (NULLS FIRST / NULLS LAST) is also never passed on: WayangSortVisitor.java:60-61 only maps getDirection().
To reproduce
A table with one empty value in an int column:
col1:int,col2:string
1;a
;b
3;c
SELECT col1, col2 FROM fs.exampleNull ORDER BY col1
on the Java platform gives:
Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.Comparable.compareTo(Object)" because "thisField" is null
at org.apache.wayang.api.sql.calcite.converter.functions.SortKeyExtractor$1.compareTo(SortKeyExtractor.java:50)
at org.apache.wayang.api.sql.calcite.converter.functions.SortKeyExtractor$1.compareTo(SortKeyExtractor.java:39)
at org.apache.wayang.java.operators.JavaSortOperator.lambda$evaluate$0(JavaSortOperator.java:79)
Expected
The NULL row is sorted instead of crashing, using Calcite's default when no null direction is given (NULLS LAST for ASC, NULLS FIRST for DESC):
ORDER BY col1→(1, a), (3, c), (null, b)ORDER BY col1 DESC→(null, b), (3, c), (1, a)ORDER BY col1 NULLS FIRST→(null, b), (1, a), (3, c)
Tested on main at 713faa7. I have a fix with tests and will open a PR for it.
- 主要言語
- Java
- スター
- 284
- フォーク
- 147
- 平均マージ
- 3日 17時間
- マージ済み PR(30日)
- 15
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/wayang のほかの issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 3 日以内に返信
-
JavaReservoirSampleOperator returns the whole input when the dataset size is unknown対応中かも @sasmith-14 が 11 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/wayang#884 · コメント 3 件 ·
メンテナーはふだん 3 日以内に返信
-
Record.compareTo() throws ClassCastException when comparing records対応中かも @harshitsingh070 が 73 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 3 日以内に返信
-
Unused parameter in function ProjectionDescriptor.createPojoJavaImplementation()対応中かも @AliRana30 が 81 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
apache/wayang#732 · コメント 3 件 ·
メンテナーはふだん 3 日以内に返信
-
SQL API: aggregates don't skip NULL values (COUNT(col) counts them, SUM and AVG throw NPE)対応中かも @AarushShetty346 が 8 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 20/100
メンテナーはふだん 3 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
micronaut-projects/micronaut-core#14585 ·
メンテナーはふだん 1 日以内に返信
-
Mend: dependency security vulnerability untriaged
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
opensearch-project/cross-cluster-replication#1805 ·
メンテナーはふだん 1 日以内に返信
-
feature request needs triage
難易度 1/5 1時間未満 初心者へのやさしさ 66/100
TeamNewPipe/NewPipe#14083 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
PCL-Community/PCL-CE#3907 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
メンテナーはふだん 2 日以内に返信