Skip to content

Commit 34be4e4

Browse files
authored
fix(query): if arg is Scalar::null or a null column ignore null will invalid (#17423)
1 parent 529f896 commit 34be4e4

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/query/service/src/pipelines/processors/transforms/window/transform_window.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -712,12 +712,11 @@ impl<T: Number> TransformWindow<T> {
712712
cur = if advance {
713713
let advance_cur = self.advance_row(cur);
714714
if advance_cur.block != cur.block {
715-
block_entry = self
716-
.blocks
717-
.get(advance_cur.block - self.first_block)
718-
.unwrap()
719-
.block
720-
.get_by_offset(arg_index);
715+
if let Some(b) = self.blocks.get(advance_cur.block - self.first_block) {
716+
block_entry = b.block.get_by_offset(arg_index);
717+
} else {
718+
return Scalar::Null;
719+
}
721720
}
722721
advance_cur
723722
} else if cur == self.frame_start {

tests/sqllogictests/suites/query/window_function/window_ignore_nulls.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,13 @@ SELECT id, user_id, order_id, lag(order_id, 1) IGNORE NULLS over ( PARTIT
139139

140140
statement ok
141141
drop TABLE default.issue2549
142+
143+
query T
144+
SELECT first_value(NULL) IGNORE NULLS OVER (PARTITION BY 'QZHc9f7');
145+
----
146+
NULL
147+
148+
query T
149+
SELECT last_value(NULL) IGNORE NULLS OVER (PARTITION BY 'QZHc9f7');
150+
----
151+
NULL

0 commit comments

Comments
 (0)