diff --git a/src/frontend/planner_test/tests/testdata/input/over_window_function.yaml b/src/frontend/planner_test/tests/testdata/input/over_window_function.yaml index bfa3bd0f9d6c6..d26296764812c 100644 --- a/src/frontend/planner_test/tests/testdata/input/over_window_function.yaml +++ b/src/frontend/planner_test/tests/testdata/input/over_window_function.yaml @@ -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); @@ -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 diff --git a/src/frontend/planner_test/tests/testdata/output/over_window_function.yaml b/src/frontend/planner_test/tests/testdata/output/over_window_function.yaml index 444297bf30a77..48e27893301b0 100644 --- a/src/frontend/planner_test/tests/testdata/output/over_window_function.yaml +++ b/src/frontend/planner_test/tests/testdata/output/over_window_function.yaml @@ -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); @@ -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