SQL API: ORDER BY throws NullPointerException when the sort column contains NULL
Maintainer thường phản hồi trong vòng 3 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- backend-api-design, databases
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Java
- Star
- 284
- Fork
- 147
- Merge trung bình
- 3 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 15
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/wayang
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 3 ngày
-
JavaReservoirSampleOperator returns the whole input when the dataset size is unknownCó thể đã có người làm @sasmith-14 đã nhận 11 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
apache/wayang#884 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Record.compareTo() throws ClassCastException when comparing recordsCó thể đã có người làm @harshitsingh070 đã nhận 73 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Unused parameter in function ProjectionDescriptor.createPojoJavaImplementation()Có thể đã có người làm @AliRana30 đã nhận 81 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
apache/wayang#732 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
SQL API: aggregates don't skip NULL values (COUNT(col) counts them, SUM and AVG throw NPE)Có thể đã có người làm @AarushShetty346 đã nhận 8 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 20/100
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của apache/wayang
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
micronaut-projects/micronaut-core#14585 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Mend: dependency security vulnerability untriaged
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
opensearch-project/cross-cluster-replication#1805 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
feature request needs triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 66/100
TeamNewPipe/NewPipe#14083 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
NeoForge 安装任务的子任务描述有误Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
PCL-Community/PCL-CE#3907 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 2 ngày