Skip to content

Commit a0d23cb

Browse files
authored
fix(cubestore): Window function don't work with only one Following bound (#7216)
1 parent 3a78ec1 commit a0d23cb

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

rust/cubestore/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cubestore/cubestore-sql-tests/src/tests.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4394,6 +4394,21 @@ async fn rolling_window_query(service: Box<dyn SqlClient>) {
43944394
rows(&[(1, 17), (2, 17), (3, 23), (4, 23), (5, 5)])
43954395
);
43964396

4397+
let r = service
4398+
.exec_query(
4399+
"SELECT day, ROLLING(SUM(n) RANGE 1 FOLLOWING) \
4400+
FROM (SELECT day, SUM(n) as n FROM s.Data GROUP BY 1) \
4401+
ROLLING_WINDOW DIMENSION day \
4402+
FROM 1 TO 5 EVERY 1 \
4403+
ORDER BY 1",
4404+
)
4405+
.await
4406+
.unwrap();
4407+
assert_eq!(
4408+
to_rows(&r),
4409+
rows(&[(1, 17), (2, 23), (3, 23), (4, 5), (5, 5)])
4410+
);
4411+
43974412
// Same, without preceding, i.e. with missing nodes.
43984413
let r = service
43994414
.exec_query(
@@ -4763,6 +4778,28 @@ async fn rolling_window_query_timestamps(service: Box<dyn SqlClient>) {
47634778
(jan[5], 5)
47644779
])
47654780
);
4781+
let r = service
4782+
.exec_query(
4783+
"select day, rolling(sum(n) range interval '1 day' following offset start) \
4784+
from (select day, sum(n) as n from s.data group by 1) \
4785+
rolling_window dimension day \
4786+
from to_timestamp('2021-01-01t00:00:00z') \
4787+
to to_timestamp('2021-01-05t00:00:00z') \
4788+
every interval '1 day' \
4789+
order by 1",
4790+
)
4791+
.await
4792+
.unwrap();
4793+
assert_eq!(
4794+
to_rows(&r),
4795+
rows(&[
4796+
(jan[1], 17),
4797+
(jan[2], 23),
4798+
(jan[3], 23),
4799+
(jan[4], 5),
4800+
(jan[5], 5)
4801+
])
4802+
);
47664803
}
47674804

47684805
async fn rolling_window_query_timestamps_exceeded(service: Box<dyn SqlClient>) {

0 commit comments

Comments
 (0)