You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d96eccb
Browse filesBrowse the repository at this point in the historyBrowse files
review: reject list ORDER BY keys in the free RANGE fallback
The peer comparison and the sort disagree on element NULLs: compare_rows
applies NULLS FIRST/LAST to the top-level value only and then goes through
ScalarValue::partial_cmp, whose partial_cmp_list always orders a NULL
element after a non-NULL one, while the sorter's make_comparator applies
the option to the elements too. Rejecting lists in the fallback is simpler
than reconciling the two.
Co-Authored-By: Claude Opus 5 <[email protected]>
select count(*) over (order by l) from (values ([[1]]), ([[2]])) t(l)
7157
7157
7158
-
# after a duration key the free-range check looks at every ORDER BY type: a
7159
-
# list of primitives is still fine,
7160
-
query I
7161
-
select count(*) over (order by d, l) from (values (arrow_cast(1, 'Duration(Second)'), [1]), (arrow_cast(1, 'Duration(Second)'), [2])) t(d, l)
7162
-
----
7163
-
1
7164
-
2
7165
-
7166
-
# but a list of nested elements is rejected at planning, instead of reaching
7167
-
# the execution error above
7158
+
# after a duration key the free-range check looks at every ORDER BY type, and
7159
+
# a list is rejected at planning even though it sorts fine: the RANGE peer
7160
+
# check (`compare_rows`, then `ScalarValue::partial_cmp`) always orders a NULL
7161
+
# list element after a non-NULL one, while the sort applies NULLS FIRST to the
7162
+
# elements as well, so with tied durations `[NULL]` and `[1]` would be sorted
7163
+
# one way and compared the other
7168
7164
query error Error during planning: RANGE window frames are not supported for ORDER BY type List
7169
-
select count(*) over (order by d, l) from (values (arrow_cast(1, 'Duration(Second)'), [struct(1)]), (arrow_cast(1, 'Duration(Second)'), [struct(2)])) t(d, l)
7165
+
select count(*) over (order by d, l nulls first) from (values (arrow_cast(1, 'Duration(Second)'), [NULL]), (arrow_cast(1, 'Duration(Second)'), [1])) t(d, l)
7170
7166
7171
-
# the check mirrors the arrow comparison kernels, not `DataType::is_nested`:
7172
-
# the kernels unwrap a single dictionary layer, so a list of doubly
7173
-
# dictionary-encoded strings is also rejected at planning
7167
+
# the check is on the type, not the values: a list without NULLs and a
7168
+
# dictionary-encoded list are rejected the same way
7174
7169
query error Error during planning: RANGE window frames are not supported for ORDER BY type List
7175
-
select count(*) over (order by d, l) from (values (arrow_cast(1, 'Duration(Second)'), [arrow_cast(arrow_cast('a', 'Dictionary(UInt32, Utf8)'), 'Dictionary(Int32, Dictionary(UInt32, Utf8))')])) t(d, l)
7170
+
select count(*) over (order by d, l) from (values (arrow_cast(1, 'Duration(Second)'), [1]), (arrow_cast(1, 'Duration(Second)'), [2])) t(d, l)
7176
7171
7177
-
# while a single dictionary layer compares fine
7178
-
query I
7179
-
select count(*) over (order by d, l) from (values (arrow_cast(1, 'Duration(Second)'), [arrow_cast('a', 'Dictionary(Int32, Utf8)')]), (arrow_cast(1, 'Duration(Second)'), [arrow_cast('b', 'Dictionary(Int32, Utf8)')])) t(d, l)
7180
-
----
7181
-
1
7182
-
2
7172
+
query error Error during planning: RANGE window frames are not supported for ORDER BY type Dictionary\(Int32, List
7173
+
select count(*) over (order by d, l) from (values (arrow_cast(1, 'Duration(Second)'), arrow_cast([1], 'Dictionary(Int32, List(Int64))')), (arrow_cast(1, 'Duration(Second)'), arrow_cast([2], 'Dictionary(Int32, List(Int64))'))) t(d, l)
7183
7174
7184
7175
# Window functions are not allowed in WHERE or HAVING: both are evaluated before
7185
7176
# window functions are computed, so they are rejected during planning
0 commit comments