File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 90
90
91
91
## Nulls
92
92
93
+ At the moment, PRQL does not guarantee any position of null values when
94
+ ordering. To be precise, they are not comparable to any other values, which
95
+ means that an ordered array may contain nulls first, last, or at any position in
96
+ between.
97
+
98
+ However, prql-compiler will emit ` NULLS LAST ` (or dialect equivalent) in all
99
+ ` ORDER BY ` clauses, with intention to make query results deterministic across
100
+ different engines. This behavior may change, see
101
+ [ issue #2622 ] ( https://github.com/PRQL/prql/issues/ ) .
102
+
103
+ To enforce ` NULLS FIRST ` or ` NULLS LAST ` right now, the following workaround can
104
+ be used:
105
+
106
+ ``` prql
107
+ from artists
108
+ sort {artist_id != null, artist_id} # nulls first
109
+ ```
110
+
111
+ ``` prql
112
+ from artists
113
+ sort {artist_id == null, artist_id} # nulls last
114
+ ```
115
+
116
+ <!--
117
+ TODO:
118
+
93
119
PRQL defaults to `NULLS LAST` when compiling to SQL. Because databases have
94
120
different defaults, the compiler emits this for all targets for which it's not a
95
121
default{{footnote: except for MSSQL, which don't support this}}.
@@ -113,4 +139,4 @@ take 42
113
139
114
140
```admonish info
115
141
Check out [DuckDB #7174](https://github.com/duckdb/duckdb/pull/7174) for a survey of various databases' implementations.
116
- ```
142
+ ``` -->
You can’t perform that action at this time.
0 commit comments