Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangstar333 committed Dec 11, 2024
1 parent d79699d commit 32445f1
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 3 deletions.
6 changes: 3 additions & 3 deletions be/src/vec/aggregate_functions/aggregate_function_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,9 @@ struct WindowFunctionFirstImpl : Data {
(!arg_ignore_null || (arg_ignore_null && !this->is_null()))) {
return;
}
if (frame_start <= frame_end &&
frame_end <= partition_start) { //rewrite last_value when under partition
this->set_is_null(); //so no need more judge
DCHECK_LE(frame_start, frame_end);
if (frame_start >= partition_end || frame_end <= partition_start) {
this->set_is_null();
return;
}
frame_start = std::max<int64_t>(frame_start, partition_start);
Expand Down
20 changes: 20 additions & 0 deletions regression-test/data/correctness_p0/test_first_value_window.out
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,23 @@ b 3 3 3 3 3 5
b \N 3 3 3 3 6
b 2 2 2 2 3 7

-- !select_default8 --
a 1 2 0
a \N \N 1
a \N \N 2
a 2 \N 3
b \N 2 4
b 3 \N 5
b \N \N 6
b 2 \N 7

-- !select_default9 --
a 1 2 0
a \N \N 1
a \N \N 2
a 2 \N 3
b \N 2 4
b 3 \N 5
b \N \N 6
b 2 \N 7

Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,40 @@ suite("test_first_value_window") {
ORDER BY uid, time_s
;
"""

qt_select_default8 """
SELECT uid
,amt
,(FIRST_VALUE(amt, true) OVER(PARTITION BY uid ORDER BY time_s ROWS between 3 following AND 6 FOLLOWING)) amt3
,time_s
FROM (
SELECT 'a' AS uid, 1 AS amt, 0 AS time_s UNION ALL
SELECT 'a' AS uid, null AS amt, 1 AS time_s UNION ALL
SELECT 'a' AS uid, null AS amt, 2 AS time_s UNION ALL
SELECT 'a' AS uid, 2 AS amt, 3 AS time_s UNION ALL
SELECT 'b' AS uid, null AS amt, 4 AS time_s UNION ALL
SELECT 'b' AS uid, 3 AS amt, 5 AS time_s UNION ALL
SELECT 'b' AS uid, null AS amt, 6 AS time_s UNION ALL
SELECT 'b' AS uid, 2 AS amt, 7 AS time_s
) t
ORDER BY uid, time_s;
"""

qt_select_default9 """
SELECT uid
,amt
,(FIRST_VALUE(amt) OVER(PARTITION BY uid ORDER BY time_s ROWS between 3 following AND 6 FOLLOWING)) amt3
,time_s
FROM (
SELECT 'a' AS uid, 1 AS amt, 0 AS time_s UNION ALL
SELECT 'a' AS uid, null AS amt, 1 AS time_s UNION ALL
SELECT 'a' AS uid, null AS amt, 2 AS time_s UNION ALL
SELECT 'a' AS uid, 2 AS amt, 3 AS time_s UNION ALL
SELECT 'b' AS uid, null AS amt, 4 AS time_s UNION ALL
SELECT 'b' AS uid, 3 AS amt, 5 AS time_s UNION ALL
SELECT 'b' AS uid, null AS amt, 6 AS time_s UNION ALL
SELECT 'b' AS uid, 2 AS amt, 7 AS time_s
) t
ORDER BY uid, time_s;
"""
}

0 comments on commit 32445f1

Please sign in to comment.