Skip to content

Commit

Permalink
Fix: handle NULL offset of NTH_VALUE window function
Browse files Browse the repository at this point in the history
  • Loading branch information
HuSen8891 committed Oct 10, 2024
1 parent 43d0bcf commit 98a9015
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion datafusion/physical-expr/src/window/nth_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl PartitionEvaluator for NthValueEvaluator {
// Negative index represents reverse direction.
(n_range >= reverse_index, true)
}
Ordering::Equal => (true, false),
Ordering::Equal => (false, false),
}
}
};
Expand Down
9 changes: 9 additions & 0 deletions datafusion/sqllogictest/test_files/window.slt
Original file line number Diff line number Diff line change
Expand Up @@ -4929,6 +4929,15 @@ SELECT v1, NTH_VALUE(v2, 0) OVER (PARTITION BY v1 ORDER BY v2) FROM t;
2 NULL
2 NULL

query I
SELECT NTH_VALUE(tt0.v1, NULL) OVER (PARTITION BY tt0.v2 ORDER BY tt0.v1) FROM t AS tt0;
----
NULL
NULL
NULL
NULL
NULL

statement ok
DROP TABLE t;

Expand Down

0 comments on commit 98a9015

Please sign in to comment.