Skip to content

Commit 9be9073

Browse files
authored
fix: ORDER BY window definition should work on null (#8444)
1 parent 1aedf8d commit 9be9073

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

datafusion/optimizer/src/analyzer/type_coercion.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,10 @@ fn coerce_window_frame(
503503
let target_type = match window_frame.units {
504504
WindowFrameUnits::Range => {
505505
if let Some(col_type) = current_types.first() {
506-
if col_type.is_numeric() || is_utf8_or_large_utf8(col_type) {
506+
if col_type.is_numeric()
507+
|| is_utf8_or_large_utf8(col_type)
508+
|| matches!(col_type, DataType::Null)
509+
{
507510
col_type
508511
} else if is_datetime(col_type) {
509512
&DataType::Interval(IntervalUnit::MonthDayNano)

datafusion/sqllogictest/test_files/window.slt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3785,3 +3785,11 @@ select a,
37853785
----
37863786
1 1
37873787
2 1
3788+
3789+
query II
3790+
select a,
3791+
rank() over (order by null RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) rnk
3792+
from (select 1 a union select 2 a) q ORDER BY a
3793+
----
3794+
1 1
3795+
2 1

0 commit comments

Comments
 (0)