-
Notifications
You must be signed in to change notification settings - Fork 591
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
358 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/frontend/planner_test/tests/testdata/input/with_ordinality.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# constant FROM | ||
- sql: | | ||
select * from unnest(array[1,2,3]) WITH ORDINALITY; | ||
expected_outputs: | ||
- batch_plan | ||
- stream_plan | ||
# lateral join | ||
- sql: | | ||
create table t(x int , arr int[]); | ||
select * from t cross join unnest(arr) WITH ORDINALITY; | ||
expected_outputs: | ||
- batch_plan | ||
- stream_plan | ||
- sql: | | ||
create table t(x int , arr int[]); | ||
select * from t cross join unnest(arr) WITH ORDINALITY as foo; | ||
expected_outputs: | ||
- batch_plan | ||
- stream_plan | ||
- sql: | | ||
create table t(x int , arr int[]); | ||
select * from t cross join unnest(arr) WITH ORDINALITY as foo(a); | ||
expected_outputs: | ||
- batch_plan | ||
- stream_plan | ||
- sql: | | ||
create table t(x int , arr int[]); | ||
select * from t cross join unnest(arr) WITH ORDINALITY as foo(a,ord); | ||
expected_outputs: | ||
- batch_plan | ||
- stream_plan | ||
- sql: | | ||
create table t(x int , arr int[]); | ||
select * from t cross join unnest(arr) WITH ORDINALITY as foo(a,ord,bar); | ||
expected_outputs: | ||
- binder_error | ||
# multiple with ordinality | ||
- sql: | | ||
create table t(x int , arr int[]); | ||
select * from t cross join unnest(arr) WITH ORDINALITY, unnest(arr) WITH ORDINALITY AS unnest_2(arr_2,ordinality_2); | ||
expected_outputs: | ||
- batch_plan | ||
- stream_plan |
162 changes: 162 additions & 0 deletions
162
src/frontend/planner_test/tests/testdata/output/with_ordinality.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
# This file is automatically generated. See `src/frontend/planner_test/README.md` for more information. | ||
- sql: | | ||
select * from unnest(array[1,2,3]) WITH ORDINALITY; | ||
batch_plan: |- | ||
BatchProject { exprs: [Unnest(ARRAY[1, 2, 3]:List(Int32)), (projected_row_id + 1:Int64) as $expr1] } | ||
└─BatchProjectSet { select_list: [Unnest(ARRAY[1, 2, 3]:List(Int32))] } | ||
└─BatchValues { rows: [[]] } | ||
stream_plan: |- | ||
StreamMaterialize { columns: [unnest, ordinality, _row_id(hidden), projected_row_id(hidden)], stream_key: [_row_id, projected_row_id], pk_columns: [_row_id, projected_row_id], pk_conflict: NoCheck } | ||
└─StreamProject { exprs: [Unnest(ARRAY[1, 2, 3]:List(Int32)), (projected_row_id + 1:Int64) as $expr1, _row_id, projected_row_id] } | ||
└─StreamProjectSet { select_list: [Unnest(ARRAY[1, 2, 3]:List(Int32)), $0] } | ||
└─StreamValues { rows: [[0:Int64]] } | ||
- sql: | | ||
create table t(x int , arr int[]); | ||
select * from t cross join unnest(arr) WITH ORDINALITY; | ||
batch_plan: |- | ||
BatchExchange { order: [], dist: Single } | ||
└─BatchProject { exprs: [t.x, t.arr, Unnest($0), (projected_row_id + 1:Int64) as $expr1] } | ||
└─BatchHashJoin { type: Inner, predicate: t.arr IS NOT DISTINCT FROM t.arr, output: all } | ||
├─BatchExchange { order: [], dist: HashShard(t.arr) } | ||
│ └─BatchScan { table: t, columns: [t.x, t.arr], distribution: SomeShard } | ||
└─BatchProjectSet { select_list: [$0, Unnest($0)] } | ||
└─BatchHashAgg { group_key: [t.arr], aggs: [] } | ||
└─BatchExchange { order: [], dist: HashShard(t.arr) } | ||
└─BatchScan { table: t, columns: [t.arr], distribution: SomeShard } | ||
stream_plan: |- | ||
StreamMaterialize { columns: [x, arr, unnest, ordinality, t._row_id(hidden), t.arr(hidden), projected_row_id(hidden)], stream_key: [t._row_id, t.arr, projected_row_id, arr], pk_columns: [t._row_id, t.arr, projected_row_id, arr], pk_conflict: NoCheck } | ||
└─StreamProject { exprs: [t.x, t.arr, Unnest($0), (projected_row_id + 1:Int64) as $expr1, t._row_id, t.arr, projected_row_id] } | ||
└─StreamHashJoin { type: Inner, predicate: t.arr IS NOT DISTINCT FROM t.arr, output: [t.x, t.arr, projected_row_id, t.arr, Unnest($0), t._row_id] } | ||
├─StreamExchange { dist: HashShard(t.arr) } | ||
│ └─StreamTableScan { table: t, columns: [t.x, t.arr, t._row_id], pk: [t._row_id], dist: UpstreamHashShard(t._row_id) } | ||
└─StreamProjectSet { select_list: [$0, Unnest($0)] } | ||
└─StreamProject { exprs: [t.arr] } | ||
└─StreamHashAgg { group_key: [t.arr], aggs: [count] } | ||
└─StreamExchange { dist: HashShard(t.arr) } | ||
└─StreamTableScan { table: t, columns: [t.arr, t._row_id], pk: [t._row_id], dist: UpstreamHashShard(t._row_id) } | ||
- sql: | | ||
create table t(x int , arr int[]); | ||
select * from t cross join unnest(arr) WITH ORDINALITY as foo; | ||
batch_plan: |- | ||
BatchExchange { order: [], dist: Single } | ||
└─BatchProject { exprs: [t.x, t.arr, Unnest($0), (projected_row_id + 1:Int64) as $expr1] } | ||
└─BatchHashJoin { type: Inner, predicate: t.arr IS NOT DISTINCT FROM t.arr, output: all } | ||
├─BatchExchange { order: [], dist: HashShard(t.arr) } | ||
│ └─BatchScan { table: t, columns: [t.x, t.arr], distribution: SomeShard } | ||
└─BatchProjectSet { select_list: [$0, Unnest($0)] } | ||
└─BatchHashAgg { group_key: [t.arr], aggs: [] } | ||
└─BatchExchange { order: [], dist: HashShard(t.arr) } | ||
└─BatchScan { table: t, columns: [t.arr], distribution: SomeShard } | ||
stream_plan: |- | ||
StreamMaterialize { columns: [x, arr, foo, ordinality, t._row_id(hidden), t.arr(hidden), projected_row_id(hidden)], stream_key: [t._row_id, t.arr, projected_row_id, arr], pk_columns: [t._row_id, t.arr, projected_row_id, arr], pk_conflict: NoCheck } | ||
└─StreamProject { exprs: [t.x, t.arr, Unnest($0), (projected_row_id + 1:Int64) as $expr1, t._row_id, t.arr, projected_row_id] } | ||
└─StreamHashJoin { type: Inner, predicate: t.arr IS NOT DISTINCT FROM t.arr, output: [t.x, t.arr, projected_row_id, t.arr, Unnest($0), t._row_id] } | ||
├─StreamExchange { dist: HashShard(t.arr) } | ||
│ └─StreamTableScan { table: t, columns: [t.x, t.arr, t._row_id], pk: [t._row_id], dist: UpstreamHashShard(t._row_id) } | ||
└─StreamProjectSet { select_list: [$0, Unnest($0)] } | ||
└─StreamProject { exprs: [t.arr] } | ||
└─StreamHashAgg { group_key: [t.arr], aggs: [count] } | ||
└─StreamExchange { dist: HashShard(t.arr) } | ||
└─StreamTableScan { table: t, columns: [t.arr, t._row_id], pk: [t._row_id], dist: UpstreamHashShard(t._row_id) } | ||
- sql: | | ||
create table t(x int , arr int[]); | ||
select * from t cross join unnest(arr) WITH ORDINALITY as foo(a); | ||
batch_plan: |- | ||
BatchExchange { order: [], dist: Single } | ||
└─BatchProject { exprs: [t.x, t.arr, Unnest($0), (projected_row_id + 1:Int64) as $expr1] } | ||
└─BatchHashJoin { type: Inner, predicate: t.arr IS NOT DISTINCT FROM t.arr, output: all } | ||
├─BatchExchange { order: [], dist: HashShard(t.arr) } | ||
│ └─BatchScan { table: t, columns: [t.x, t.arr], distribution: SomeShard } | ||
└─BatchProjectSet { select_list: [$0, Unnest($0)] } | ||
└─BatchHashAgg { group_key: [t.arr], aggs: [] } | ||
└─BatchExchange { order: [], dist: HashShard(t.arr) } | ||
└─BatchScan { table: t, columns: [t.arr], distribution: SomeShard } | ||
stream_plan: |- | ||
StreamMaterialize { columns: [x, arr, a, ordinality, t._row_id(hidden), t.arr(hidden), projected_row_id(hidden)], stream_key: [t._row_id, t.arr, projected_row_id, arr], pk_columns: [t._row_id, t.arr, projected_row_id, arr], pk_conflict: NoCheck } | ||
└─StreamProject { exprs: [t.x, t.arr, Unnest($0), (projected_row_id + 1:Int64) as $expr1, t._row_id, t.arr, projected_row_id] } | ||
└─StreamHashJoin { type: Inner, predicate: t.arr IS NOT DISTINCT FROM t.arr, output: [t.x, t.arr, projected_row_id, t.arr, Unnest($0), t._row_id] } | ||
├─StreamExchange { dist: HashShard(t.arr) } | ||
│ └─StreamTableScan { table: t, columns: [t.x, t.arr, t._row_id], pk: [t._row_id], dist: UpstreamHashShard(t._row_id) } | ||
└─StreamProjectSet { select_list: [$0, Unnest($0)] } | ||
└─StreamProject { exprs: [t.arr] } | ||
└─StreamHashAgg { group_key: [t.arr], aggs: [count] } | ||
└─StreamExchange { dist: HashShard(t.arr) } | ||
└─StreamTableScan { table: t, columns: [t.arr, t._row_id], pk: [t._row_id], dist: UpstreamHashShard(t._row_id) } | ||
- sql: | | ||
create table t(x int , arr int[]); | ||
select * from t cross join unnest(arr) WITH ORDINALITY as foo(a,ord); | ||
batch_plan: |- | ||
BatchExchange { order: [], dist: Single } | ||
└─BatchProject { exprs: [t.x, t.arr, Unnest($0), (projected_row_id + 1:Int64) as $expr1] } | ||
└─BatchHashJoin { type: Inner, predicate: t.arr IS NOT DISTINCT FROM t.arr, output: all } | ||
├─BatchExchange { order: [], dist: HashShard(t.arr) } | ||
│ └─BatchScan { table: t, columns: [t.x, t.arr], distribution: SomeShard } | ||
└─BatchProjectSet { select_list: [$0, Unnest($0)] } | ||
└─BatchHashAgg { group_key: [t.arr], aggs: [] } | ||
└─BatchExchange { order: [], dist: HashShard(t.arr) } | ||
└─BatchScan { table: t, columns: [t.arr], distribution: SomeShard } | ||
stream_plan: |- | ||
StreamMaterialize { columns: [x, arr, a, ord, t._row_id(hidden), t.arr(hidden), projected_row_id(hidden)], stream_key: [t._row_id, t.arr, projected_row_id, arr], pk_columns: [t._row_id, t.arr, projected_row_id, arr], pk_conflict: NoCheck } | ||
└─StreamProject { exprs: [t.x, t.arr, Unnest($0), (projected_row_id + 1:Int64) as $expr1, t._row_id, t.arr, projected_row_id] } | ||
└─StreamHashJoin { type: Inner, predicate: t.arr IS NOT DISTINCT FROM t.arr, output: [t.x, t.arr, projected_row_id, t.arr, Unnest($0), t._row_id] } | ||
├─StreamExchange { dist: HashShard(t.arr) } | ||
│ └─StreamTableScan { table: t, columns: [t.x, t.arr, t._row_id], pk: [t._row_id], dist: UpstreamHashShard(t._row_id) } | ||
└─StreamProjectSet { select_list: [$0, Unnest($0)] } | ||
└─StreamProject { exprs: [t.arr] } | ||
└─StreamHashAgg { group_key: [t.arr], aggs: [count] } | ||
└─StreamExchange { dist: HashShard(t.arr) } | ||
└─StreamTableScan { table: t, columns: [t.arr, t._row_id], pk: [t._row_id], dist: UpstreamHashShard(t._row_id) } | ||
- sql: | | ||
create table t(x int , arr int[]); | ||
select * from t cross join unnest(arr) WITH ORDINALITY as foo(a,ord,bar); | ||
binder_error: 'Bind error: table "foo" has 2 columns available but 3 column aliases specified' | ||
- sql: | | ||
create table t(x int , arr int[]); | ||
select * from t cross join unnest(arr) WITH ORDINALITY, unnest(arr) WITH ORDINALITY AS unnest_2(arr_2,ordinality_2); | ||
batch_plan: |- | ||
BatchExchange { order: [], dist: Single } | ||
└─BatchProject { exprs: [t.x, t.arr, Unnest($0), (projected_row_id + 1:Int64) as $expr1, Unnest($0), (projected_row_id + 1:Int64) as $expr2] } | ||
└─BatchHashJoin { type: Inner, predicate: t.arr IS NOT DISTINCT FROM t.arr, output: all } | ||
├─BatchHashJoin { type: Inner, predicate: t.arr IS NOT DISTINCT FROM t.arr, output: all } | ||
│ ├─BatchExchange { order: [], dist: HashShard(t.arr) } | ||
│ │ └─BatchScan { table: t, columns: [t.x, t.arr], distribution: SomeShard } | ||
│ └─BatchProjectSet { select_list: [$0, Unnest($0)] } | ||
│ └─BatchHashAgg { group_key: [t.arr], aggs: [] } | ||
│ └─BatchExchange { order: [], dist: HashShard(t.arr) } | ||
│ └─BatchScan { table: t, columns: [t.arr], distribution: SomeShard } | ||
└─BatchProjectSet { select_list: [$0, Unnest($0)] } | ||
└─BatchHashAgg { group_key: [t.arr], aggs: [] } | ||
└─BatchHashJoin { type: Inner, predicate: t.arr IS NOT DISTINCT FROM t.arr, output: [t.arr] } | ||
├─BatchExchange { order: [], dist: HashShard(t.arr) } | ||
│ └─BatchScan { table: t, columns: [t.arr], distribution: SomeShard } | ||
└─BatchProjectSet { select_list: [$0, Unnest($0)] } | ||
└─BatchHashAgg { group_key: [t.arr], aggs: [] } | ||
└─BatchExchange { order: [], dist: HashShard(t.arr) } | ||
└─BatchScan { table: t, columns: [t.arr], distribution: SomeShard } | ||
stream_plan: |- | ||
StreamMaterialize { columns: [x, arr, unnest, ordinality, arr_2, ordinality_2, t._row_id(hidden), t.arr(hidden), projected_row_id(hidden), t.arr#1(hidden), projected_row_id#1(hidden)], stream_key: [t._row_id, t.arr, projected_row_id, arr, t.arr#1, projected_row_id#1], pk_columns: [t._row_id, t.arr, projected_row_id, arr, t.arr#1, projected_row_id#1], pk_conflict: NoCheck } | ||
└─StreamProject { exprs: [t.x, t.arr, Unnest($0), $expr1, Unnest($0), (projected_row_id + 1:Int64) as $expr2, t._row_id, t.arr, projected_row_id, t.arr, projected_row_id] } | ||
└─StreamHashJoin { type: Inner, predicate: t.arr IS NOT DISTINCT FROM t.arr, output: [t.x, t.arr, Unnest($0), $expr1, projected_row_id, t.arr, Unnest($0), t._row_id, t.arr, projected_row_id] } | ||
├─StreamShare { id: 8 } | ||
│ └─StreamProject { exprs: [t.x, t.arr, Unnest($0), (projected_row_id + 1:Int64) as $expr1, t._row_id, t.arr, projected_row_id] } | ||
│ └─StreamHashJoin { type: Inner, predicate: t.arr IS NOT DISTINCT FROM t.arr, output: [t.x, t.arr, projected_row_id, t.arr, Unnest($0), t._row_id] } | ||
│ ├─StreamExchange { dist: HashShard(t.arr) } | ||
│ │ └─StreamTableScan { table: t, columns: [t.x, t.arr, t._row_id], pk: [t._row_id], dist: UpstreamHashShard(t._row_id) } | ||
│ └─StreamProjectSet { select_list: [$0, Unnest($0)] } | ||
│ └─StreamProject { exprs: [t.arr] } | ||
│ └─StreamHashAgg { group_key: [t.arr], aggs: [count] } | ||
│ └─StreamExchange { dist: HashShard(t.arr) } | ||
│ └─StreamTableScan { table: t, columns: [t.arr, t._row_id], pk: [t._row_id], dist: UpstreamHashShard(t._row_id) } | ||
└─StreamProjectSet { select_list: [$0, Unnest($0)] } | ||
└─StreamProject { exprs: [t.arr] } | ||
└─StreamHashAgg { group_key: [t.arr], aggs: [count] } | ||
└─StreamShare { id: 8 } | ||
└─StreamProject { exprs: [t.x, t.arr, Unnest($0), (projected_row_id + 1:Int64) as $expr1, t._row_id, t.arr, projected_row_id] } | ||
└─StreamHashJoin { type: Inner, predicate: t.arr IS NOT DISTINCT FROM t.arr, output: [t.x, t.arr, projected_row_id, t.arr, Unnest($0), t._row_id] } | ||
├─StreamExchange { dist: HashShard(t.arr) } | ||
│ └─StreamTableScan { table: t, columns: [t.x, t.arr, t._row_id], pk: [t._row_id], dist: UpstreamHashShard(t._row_id) } | ||
└─StreamProjectSet { select_list: [$0, Unnest($0)] } | ||
└─StreamProject { exprs: [t.arr] } | ||
└─StreamHashAgg { group_key: [t.arr], aggs: [count] } | ||
└─StreamExchange { dist: HashShard(t.arr) } | ||
└─StreamTableScan { table: t, columns: [t.arr, t._row_id], pk: [t._row_id], dist: UpstreamHashShard(t._row_id) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.