AarushShetty346 opened a new pull request, #892:
URL: https://github.com/apache/wayang/pull/892

   Fixes #890
   
   ### What changes were proposed in this pull request?
   
   `ORDER BY` on a column with NULL values threw a `NullPointerException` in 
`SortKeyExtractor`, because it called `compareTo` on the null value.
   
   - `WayangSortVisitor` now passes the null direction of each field collation 
to `SortKeyExtractor`. If it is `UNSPECIFIED`, it uses 
`Direction.defaultNullDirection()` (LAST for ASC, FIRST for DESC), which is 
Calcite's default.
   - `SortKeyExtractor.compareTo` places nulls by that direction before 
comparing the values. `NULLS FIRST` / `NULLS LAST` aren't flipped for DESC, so 
they stay absolute like in standard SQL.
   - The existing two-argument constructor is kept and uses the default null 
directions.
   
   ### How was this patch tested?
   
   I added `javaSortWithNullsAscending`, `javaSortWithNullsDescending` and 
`javaSortWithNullsFirst` to `SqlToWayangRelTest`. They use a new three-row 
`exampleNull.csv` with one empty `col1`. All three fail with the NPE on main 
and pass with this change. The other `wayang-api-sql` tests still pass (34 in 
total).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to