SQL API: aggregates don't skip NULL values (COUNT(col) counts them, SUM and AVG throw NPE)
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 20/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Java
- Star
- 284
- Fork
- 147
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 13
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ó 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 2 ngày
-
JavaReservoirSampleOperator returns the whole input when the dataset size is unknownCó thể đã có người làm @sasmith-14 đã nhận 7 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 2 ngày
-
Record.compareTo() throws ClassCastException when comparing recordsCó thể đã có người làm @harshitsingh070 đã nhận 69 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 2 ngày
-
Unused parameter in function ProjectionDescriptor.createPojoJavaImplementation()Có thể đã có người làm @AliRana30 đã nhận 77 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 2 ngày
-
DISCLAIMER and some "(incubating)" references are still around after graduationCó thể đã có người làm @sasmith-14 đã nhận 1 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 66/100
apache/wayang#895 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 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 68/100
jenkins-infra/plugin-modernizer-tool#2070 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Event search answers 500 when calendars, attendees or organizers holds a null elementCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởai-driven-qa bug Minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
linagora/twake-calendar-side-service#1615 · 1 bình luận ·
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 62/100
eclipse-tradista/tradista#371 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Failed to start Rescue missionĐang mởcritical
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
mars-sim/mars-sim#2199 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG-02] Endpoints /assistente/relatorio/*/preview retornam 404 ("Ver na tela" dos relatórios)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
projeto-ong-amar/projeto-ong-amar-backend#26 ·
Maintainer thường phản hồi trong vòng 1 ngày