Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
We have not specified what Calcite does if you do not specify NULLS FIRST or NULLS LAST. The policy seems to have been to always sort nulls first, but was not consistent (see CALCITE-969).
Now Calcite will treat nulls as HIGH by default. That means NULLS LAST is assumed for ASC, NULLS FIRST is assumed for DESC. This is the same behavior as Oracle.
If a project does not like this behavior, they can change the new parameter "defaultNullCollation", which allows alternative policies. Its value is defined by
enum NullCollation { LOW, HIGH, FIRST, LAST }
The "defaultNullCollation" parameter only applies to user SQL. If you create a RelFieldCollation via RelBuilder or directly, and do not specify a NullDirection value, you will get HIGH semantics. We used to use NullDirection.UNSPECIFIED quite widely in RelNode land, and now it is very rarely used, except with Direction.CLUSTERED.