SQL API: ORDER BY throws NullPointerException when the sort column contains NULL
Los mantenedores suelen responder en 3 días
@AarushShetty346 ya está trabajando en esto.
Desde el 18/11/2026.
- #892 de @AarushShetty346 — abierto
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Área
- backend-api-design, databases
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Java
- Estrellas
- 284
- Forks
- 147
- Merge medio
- 3 d 17 h
- PR fusionados (30 d)
- 15
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/wayang
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 3 días
-
JavaReservoirSampleOperator returns the whole input when the dataset size is unknownPosiblemente ocupada @sasmith-14 la tomó hace 11 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
apache/wayang#884 · 3 comentarios ·
Los mantenedores suelen responder en 3 días
-
Record.compareTo() throws ClassCastException when comparing recordsPosiblemente ocupada @harshitsingh070 la tomó hace 73 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 3 días
-
Unused parameter in function ProjectionDescriptor.createPojoJavaImplementation()Posiblemente ocupada @AliRana30 la tomó hace 81 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
apache/wayang#732 · 3 comentarios ·
Los mantenedores suelen responder en 3 días
-
SQL API: aggregates don't skip NULL values (COUNT(col) counts them, SUM and AVG throw NPE)Posiblemente ocupada @AarushShetty346 la tomó hace 8 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 20/100
Los mantenedores suelen responder en 3 días
Todos los issues de apache/wayang
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
micronaut-projects/micronaut-core#14585 ·
Los mantenedores suelen responder en 1 día
-
Mend: dependency security vulnerability untriaged
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
opensearch-project/cross-cluster-replication#1805 ·
Los mantenedores suelen responder en 1 día
-
feature request needs triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 66/100
TeamNewPipe/NewPipe#14083 ·
Los mantenedores suelen responder en 1 día
-
NeoForge 安装任务的子任务描述有误Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
PCL-Community/PCL-CE#3907 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
Los mantenedores suelen responder en 2 días