Skip to content

Commit

Permalink
add planner tests
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Chien <[email protected]>
  • Loading branch information
stdrc committed Jan 24, 2024
1 parent 87bd69d commit 68b4623
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,17 @@
create table t(x int, y int);
select x, y, max(x) over(PARTITION BY y ORDER BY x RANGE 100 PRECEDING) from t;
expected_outputs:
- binder_error
- logical_plan
- stream_error
- batch_error
- id: aggregate with over clause, range frame definition with between
sql: |
create table t(x int, y int);
select x, y, max(x) over(PARTITION BY y ORDER BY x RANGE BETWEEN 100 PRECEDING and UNBOUNDED FOLLOWING) from t;
expected_outputs:
- binder_error
- logical_plan
- stream_error
- batch_error
- id: aggregate with over clause, unbounded range, with ORDER BY
sql: |
create table t(x int, y int);
Expand Down Expand Up @@ -547,3 +551,22 @@
expected_outputs:
- optimized_logical_plan_for_stream
- optimized_logical_plan_for_batch

# Range frames
- sql: |
create table t (i int, bi bigint, d decimal, f float, da date, t time, ts timestamp, tstz timestamptz, itv interval);
select
count(*) over (partition by 1::int order by i range 1 preceding),
count(*) over (partition by 1::int order by bi range 1 preceding),
count(*) over (partition by 1::int order by d range 1.5 preceding),
count(*) over (partition by 1::int order by f range 1.5 preceding),
-- count(*) over (partition by 1::int order by da range '1 day' preceding), -- `date` not supported yet
-- count(*) over (partition by 1::int order by t range '1 min' preceding), -- `time` not supported yet
count(*) over (partition by 1::int order by ts range '1 day 1 hour' preceding),
count(*) over (partition by 1::int order by tstz range '1 min' preceding)
from t;
expected_outputs:
- logical_plan
- optimized_logical_plan_for_stream
- stream_error
- batch_error
Original file line number Diff line number Diff line change
Expand Up @@ -259,22 +259,32 @@
sql: |
create table t(x int, y int);
select x, y, max(x) over(PARTITION BY y ORDER BY x RANGE 100 PRECEDING) from t;
binder_error: |
Failed to bind expression: max(x) OVER (PARTITION BY y ORDER BY x RANGE 100 PRECEDING)
Caused by:
Feature is not yet implemented: window frame in `RANGE` mode is not supported yet
Tracking issue: https://github.com/risingwavelabs/risingwave/issues/9124
logical_plan: |-
LogicalProject { exprs: [t.x, t.y, max] }
└─LogicalOverWindow { window_functions: [max(t.x) OVER(PARTITION BY t.y ORDER BY t.x ASC RANGE BETWEEN 100 PRECEDING AND CURRENT ROW)] }
└─LogicalProject { exprs: [t.x, t.y, t._row_id] }
└─LogicalScan { table: t, columns: [t.x, t.y, t._row_id] }
batch_error: |-
Feature is not yet implemented: Window function with `RANGE` frame is not supported yet
No tracking issue yet. Feel free to submit a feature request at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Ffeature&template=feature_request.yml
stream_error: |-
Feature is not yet implemented: Window function with `RANGE` frame is not supported yet
No tracking issue yet. Feel free to submit a feature request at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Ffeature&template=feature_request.yml
- id: aggregate with over clause, range frame definition with between
sql: |
create table t(x int, y int);
select x, y, max(x) over(PARTITION BY y ORDER BY x RANGE BETWEEN 100 PRECEDING and UNBOUNDED FOLLOWING) from t;
binder_error: |
Failed to bind expression: max(x) OVER (PARTITION BY y ORDER BY x RANGE BETWEEN 100 PRECEDING AND UNBOUNDED FOLLOWING)
Caused by:
Feature is not yet implemented: window frame in `RANGE` mode is not supported yet
Tracking issue: https://github.com/risingwavelabs/risingwave/issues/9124
logical_plan: |-
LogicalProject { exprs: [t.x, t.y, max] }
└─LogicalOverWindow { window_functions: [max(t.x) OVER(PARTITION BY t.y ORDER BY t.x ASC RANGE BETWEEN 100 PRECEDING AND UNBOUNDED FOLLOWING)] }
└─LogicalProject { exprs: [t.x, t.y, t._row_id] }
└─LogicalScan { table: t, columns: [t.x, t.y, t._row_id] }
batch_error: |-
Feature is not yet implemented: Window function with `RANGE` frame is not supported yet
No tracking issue yet. Feel free to submit a feature request at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Ffeature&template=feature_request.yml
stream_error: |-
Feature is not yet implemented: Window function with `RANGE` frame is not supported yet
No tracking issue yet. Feel free to submit a feature request at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Ffeature&template=feature_request.yml
- id: aggregate with over clause, unbounded range, with ORDER BY
sql: |
create table t(x int, y int);
Expand Down Expand Up @@ -1115,3 +1125,41 @@
└─LogicalOverWindow { window_functions: [count() OVER(PARTITION BY 1:Int32 ORDER BY t.b ASC ROWS BETWEEN 10 FOLLOWING AND 1 FOLLOWING)] }
└─LogicalProject { exprs: [t.b, 1:Int32] }
└─LogicalScan { table: t, columns: [t.b] }
- sql: |
create table t (i int, bi bigint, d decimal, f float, da date, t time, ts timestamp, tstz timestamptz, itv interval);
select
count(*) over (partition by 1::int order by i range 1 preceding),
count(*) over (partition by 1::int order by bi range 1 preceding),
count(*) over (partition by 1::int order by d range 1.5 preceding),
count(*) over (partition by 1::int order by f range 1.5 preceding),
-- count(*) over (partition by 1::int order by da range '1 day' preceding), -- `date` not supported yet
-- count(*) over (partition by 1::int order by t range '1 min' preceding), -- `time` not supported yet
count(*) over (partition by 1::int order by ts range '1 day 1 hour' preceding),
count(*) over (partition by 1::int order by tstz range '1 min' preceding)
from t;
logical_plan: |-
LogicalProject { exprs: [count, count, count, count, count, count] }
└─LogicalOverWindow { window_functions: [count() OVER(PARTITION BY 1:Int32 ORDER BY t.i ASC RANGE BETWEEN 1 PRECEDING AND CURRENT ROW), count() OVER(PARTITION BY 1:Int32 ORDER BY t.bi ASC RANGE BETWEEN 1 PRECEDING AND CURRENT ROW), count() OVER(PARTITION BY 1:Int32 ORDER BY t.d ASC RANGE BETWEEN 1.5 PRECEDING AND CURRENT ROW), count() OVER(PARTITION BY 1:Int32 ORDER BY t.f ASC RANGE BETWEEN 1.5 PRECEDING AND CURRENT ROW), count() OVER(PARTITION BY 1:Int32 ORDER BY t.ts ASC RANGE BETWEEN 1 day 01:00:00 PRECEDING AND CURRENT ROW), count() OVER(PARTITION BY 1:Int32 ORDER BY t.tstz ASC RANGE BETWEEN 00:01:00 PRECEDING AND CURRENT ROW)] }
└─LogicalProject { exprs: [t.i, t.bi, t.d, t.f, t.da, t.t, t.ts, t.tstz, t.itv, t._row_id, 1:Int32] }
└─LogicalScan { table: t, columns: [t.i, t.bi, t.d, t.f, t.da, t.t, t.ts, t.tstz, t.itv, t._row_id] }
optimized_logical_plan_for_stream: |-
LogicalProject { exprs: [count, count, count, count, count, count] }
└─LogicalOverWindow { window_functions: [count() OVER(PARTITION BY 1:Int32 ORDER BY t.tstz ASC RANGE BETWEEN 00:01:00 PRECEDING AND CURRENT ROW)] }
└─LogicalProject { exprs: [t.tstz, 1:Int32, count, count, count, count, count] }
└─LogicalOverWindow { window_functions: [count() OVER(PARTITION BY 1:Int32 ORDER BY t.ts ASC RANGE BETWEEN 1 day 01:00:00 PRECEDING AND CURRENT ROW)] }
└─LogicalProject { exprs: [t.ts, t.tstz, 1:Int32, count, count, count, count] }
└─LogicalOverWindow { window_functions: [count() OVER(PARTITION BY 1:Int32 ORDER BY t.f ASC RANGE BETWEEN 1.5 PRECEDING AND CURRENT ROW)] }
└─LogicalProject { exprs: [t.f, t.ts, t.tstz, 1:Int32, count, count, count] }
└─LogicalOverWindow { window_functions: [count() OVER(PARTITION BY 1:Int32 ORDER BY t.d ASC RANGE BETWEEN 1.5 PRECEDING AND CURRENT ROW)] }
└─LogicalProject { exprs: [t.d, t.f, t.ts, t.tstz, 1:Int32, count, count] }
└─LogicalOverWindow { window_functions: [count() OVER(PARTITION BY 1:Int32 ORDER BY t.bi ASC RANGE BETWEEN 1 PRECEDING AND CURRENT ROW)] }
└─LogicalProject { exprs: [t.bi, t.d, t.f, t.ts, t.tstz, 1:Int32, count] }
└─LogicalOverWindow { window_functions: [count() OVER(PARTITION BY 1:Int32 ORDER BY t.i ASC RANGE BETWEEN 1 PRECEDING AND CURRENT ROW)] }
└─LogicalProject { exprs: [t.i, t.bi, t.d, t.f, t.ts, t.tstz, 1:Int32] }
└─LogicalScan { table: t, columns: [t.i, t.bi, t.d, t.f, t.ts, t.tstz] }
batch_error: |-
Feature is not yet implemented: Window function with `RANGE` frame is not supported yet
No tracking issue yet. Feel free to submit a feature request at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Ffeature&template=feature_request.yml
stream_error: |-
Feature is not yet implemented: Window function with `RANGE` frame is not supported yet
No tracking issue yet. Feel free to submit a feature request at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Ffeature&template=feature_request.yml

0 comments on commit 68b4623

Please sign in to comment.