-
Notifications
You must be signed in to change notification settings - Fork 599
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support create table with map type
support cast improve check
- Loading branch information
Showing
15 changed files
with
227 additions
and
37 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
This file was deleted.
Oops, something went wrong.
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,120 @@ | ||
statement ok | ||
SET RW_IMPLICIT_FLUSH TO true; | ||
|
||
|
||
statement error | ||
create table t (m map (float, float)); | ||
---- | ||
db error: ERROR: Failed to run the query | ||
|
||
Caused by: | ||
invalid map key type: double precision | ||
|
||
|
||
query error | ||
select map_from_entries(array[1.0,2.0,3.0], array[1,2,3]); | ||
---- | ||
db error: ERROR: Failed to run the query | ||
|
||
Caused by these errors (recent errors listed first): | ||
1: Failed to bind expression: map_from_entries(ARRAY[1.0, 2.0, 3.0], ARRAY[1, 2, 3]) | ||
2: Expr error | ||
3: invalid map key type: numeric | ||
|
||
|
||
query error | ||
select map_from_entries(array[1,1,3], array[1,2,3]); | ||
---- | ||
db error: ERROR: Failed to run the query | ||
|
||
Caused by these errors (recent errors listed first): | ||
1: Expr error | ||
2: error while evaluating expression `map('{1,1,3}', '{1,2,3}')` | ||
3: map keys must be unique | ||
|
||
|
||
query ? | ||
select map_from_entries(array[1,2,3], array[1,null,3]); | ||
---- | ||
{"1":1,"2":NULL,"3":3} | ||
|
||
|
||
query error | ||
select map_from_entries(array[1,null,3], array[1,2,3]); | ||
---- | ||
db error: ERROR: Failed to run the query | ||
|
||
Caused by these errors (recent errors listed first): | ||
1: Expr error | ||
2: error while evaluating expression `map('{1,NULL,3}', '{1,2,3}')` | ||
3: map keys must not be NULL | ||
|
||
|
||
query error | ||
select map_from_entries(array[1,3], array[1,2,3]); | ||
---- | ||
db error: ERROR: Failed to run the query | ||
|
||
Caused by these errors (recent errors listed first): | ||
1: Expr error | ||
2: error while evaluating expression `map('{1,3}', '{1,2,3}')` | ||
3: map keys and values have different length | ||
|
||
|
||
query error | ||
select map_from_entries(array[1,2], array[1,2]) = map_from_entries(array[2,1], array[2,1]); | ||
---- | ||
db error: ERROR: Failed to run the query | ||
|
||
Caused by these errors (recent errors listed first): | ||
1: Failed to bind expression: map_from_entries(ARRAY[1, 2], ARRAY[1, 2]) = map_from_entries(ARRAY[2, 1], ARRAY[2, 1]) | ||
2: function equal(map(integer,integer), map(integer,integer)) does not exist | ||
|
||
|
||
statement ok | ||
create table t ( | ||
m1 map(varchar, float), | ||
m2 map(int, bool), | ||
m3 map(varchar, map(varchar, varchar)), | ||
l map(varchar,int)[], | ||
s struct<m map(varchar, struct<x int>)>, | ||
); | ||
|
||
|
||
statement ok | ||
insert into t values ( | ||
map_from_entries(array['a','b','c'], array[1.0,2.0,3.0]::float[]), | ||
map_from_entries(array[1,2,3], array[true,false,true]), | ||
map_from_entries(array['a','b'], | ||
array[ | ||
map_from_entries(array['a1'], array['a2']), | ||
map_from_entries(array['b1'], array['b2']) | ||
] | ||
), | ||
array[ | ||
map_from_entries(array['a','b','c'], array[1,2,3]), | ||
map_from_entries(array['d','e','f'], array[4,5,6]) | ||
], | ||
row( | ||
map_from_entries(array['a','b','c'], array[row(1),row(2),row(3)]::struct<x int>[]) | ||
) | ||
); | ||
|
||
# cast(map(character varying,integer)) -> map(character varying,double precision) | ||
query ? | ||
select map_from_entries(array['a','b','c'], array[1,2,3])::map(varchar,float); | ||
---- | ||
{"a":1,"b":2,"c":3} | ||
|
||
|
||
statement ok | ||
insert into t(m1) values (map_from_entries(array['a','b','c'], array[1,2,3])); | ||
|
||
query ????? rowsort | ||
select * from t; | ||
---- | ||
{"a":1,"b":2,"c":3} NULL NULL NULL NULL | ||
{"a":1,"b":2,"c":3} {"1":t,"2":f,"3":t} {"a":{"a1":a2},"b":{"b1":b2}} {"{\"a\":1,\"b\":2,\"c\":3}","{\"d\":4,\"e\":5,\"f\":6}"} ("{""a"":(1),""b"":(2),""c"":(3)}") | ||
|
||
statement ok | ||
drop table t; |
This file was deleted.
Oops, something went wrong.
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
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
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
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
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.