Skip to content

Commit

Permalink
add & update planner tests
Browse files Browse the repository at this point in the history
Signed-off-by: Bugen Zhao <[email protected]>
  • Loading branch information
BugenZhao committed Nov 21, 2024
1 parent 2473a08 commit 3f12a20
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 4 deletions.
17 changes: 17 additions & 0 deletions src/frontend/planner_test/tests/testdata/input/cast.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,20 @@
select count(*) FILTER(WHERE 'y') from t;
expected_outputs:
- batch_plan
- name: composite type cast error message (array)
sql: |
select '[]'::int[]::bytea[];
expected_outputs:
- binder_error
- name: composite type cast error message (struct)
sql: |
create table t (v struct<a struct<b int>, c bool>);
select v::struct<d struct<e bytea>, f bool> from t;
expected_outputs:
- binder_error
- name: composite type cast error message (map)
sql: |
create table t (v map(int, int));
select v::map(int, bytea) from t;
expected_outputs:
- binder_error
2 changes: 1 addition & 1 deletion src/frontend/planner_test/tests/testdata/output/array.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
sql: |
create table t (v1 varchar[]);
insert into t values ('{c,' || 'd}');
binder_error: 'Bind error: cannot cast type "character varying" to "character varying[]" in Assign context'
binder_error: cannot cast type "character varying" to "character varying[]" in Assign context
- name: string to varchar[] in explicit context
sql: |
select ('{c,' || 'd}')::varchar[];
Expand Down
32 changes: 32 additions & 0 deletions src/frontend/planner_test/tests/testdata/output/cast.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,35 @@
└─BatchExchange { order: [], dist: Single }
└─BatchSimpleAgg { aggs: [count] }
└─BatchScan { table: t, columns: [], distribution: SomeShard }
- name: composite type cast error message (array)
sql: |
select '[]'::int[]::bytea[];
binder_error: |
Failed to bind expression: CAST(CAST('[]' AS INT[]) AS BYTEA[])
Caused by these errors (recent errors listed first):
1: cannot cast type "integer[]" to "bytea[]" in Explicit context
2: cannot cast type "integer" to "bytea" in Explicit context
- name: composite type cast error message (struct)
sql: |
create table t (v struct<a struct<b int>, c bool>);
select v::struct<d struct<e bytea>, f bool> from t;
binder_error: |
Failed to bind expression: CAST(v AS STRUCT<d STRUCT<e BYTEA>, f BOOLEAN>)
Caused by these errors (recent errors listed first):
1: cannot cast type "struct<a struct<b integer>, c boolean>" to "struct<d struct<e bytea>, f boolean>" in Explicit context
2: cannot cast type "struct<b integer>" to "struct<e bytea>" in Explicit context
3: cannot cast type "integer" to "bytea" in Explicit context
- name: composite type cast error message (map)
sql: |
create table t (v map(int, int));
select v::map(int, bytea) from t;
binder_error: |
Failed to bind expression: CAST(v AS MAP(INT,BYTEA))
Caused by these errors (recent errors listed first):
1: cannot cast type "map(integer,integer)" to "map(integer,bytea)" in Explicit context
2: cannot cast type "struct<key integer, value integer>[]" to "struct<key integer, value bytea>[]" in Explicit context
3: cannot cast type "struct<key integer, value integer>" to "struct<key integer, value bytea>" in Explicit context
4: cannot cast type "integer" to "bytea" in Explicit context
2 changes: 1 addition & 1 deletion src/frontend/planner_test/tests/testdata/output/expr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@
Failed to bind expression: concat_ws(v1, 1.2)
Caused by:
Bind error: cannot cast type "integer" to "character varying" in Implicit context
cannot cast type "integer" to "character varying" in Implicit context
- sql: |
create table t (v1 int);
select concat_ws() from t;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@
- sql: |
CREATE TABLE a (c STRUCT<i STRUCT<a INTEGER>, j INTEGER>);
INSERT INTO a VALUES (1);
binder_error: 'Bind error: cannot cast type "integer" to "struct<i struct<a integer>, j integer>" in Assign context'
binder_error: cannot cast type "integer" to "struct<i struct<a integer>, j integer>" in Assign context
- name: test struct type alignment in CASE expression
sql: |
select CASE WHEN false THEN ROW(0, INTERVAL '1') WHEN true THEN ROW(1.1, INTERVAL '1') ELSE ROW(1, INTERVAL '1') END;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- sql: |
create table t (v1 int, v2 int);
update t set v1 = true;
binder_error: 'Bind error: cannot cast type "boolean" to "integer" in Assign context'
binder_error: cannot cast type "boolean" to "integer" in Assign context
- sql: |
create table t (v1 int, v2 int);
update t set v1 = v2 + 1;
Expand Down

0 comments on commit 3f12a20

Please sign in to comment.