2021-01-06 10:53:14 +00:00
|
|
|
set allow_experimental_map_type = 1;
|
|
|
|
|
|
|
|
-- String type
|
|
|
|
drop table if exists table_map;
|
2021-11-07 12:20:35 +00:00
|
|
|
create table table_map (a Map(String, String), b String, c Array(String), d Array(String)) engine = Memory;
|
|
|
|
insert into table_map values ({'name':'zhangsan', 'age':'10'}, 'name', ['name', 'age'], ['zhangsan', '10']), ({'name':'lisi', 'gender':'female'},'age',['name', 'gender'], ['lisi', 'female']);
|
2021-01-06 10:53:14 +00:00
|
|
|
select mapContains(a, 'name') from table_map;
|
|
|
|
select mapContains(a, 'gender') from table_map;
|
|
|
|
select mapContains(a, 'abc') from table_map;
|
|
|
|
select mapContains(a, b) from table_map;
|
2021-09-22 17:31:49 +00:00
|
|
|
select mapContains(a, 10) from table_map; -- { serverError 386 }
|
2021-01-06 10:53:14 +00:00
|
|
|
select mapKeys(a) from table_map;
|
2021-11-07 12:20:35 +00:00
|
|
|
select mapFromArrays(c, d) from table_map;
|
2021-01-06 10:53:14 +00:00
|
|
|
drop table if exists table_map;
|
|
|
|
|
2021-11-07 12:51:14 +00:00
|
|
|
CREATE TABLE table_map (a Map(UInt8, Int), b UInt8, c UInt32, d Array(String), e Array(String)) engine = MergeTree order by tuple();
|
|
|
|
insert into table_map select map(number, number), number, number, [number, number, number], [number*2, number*3, number*4] from numbers(1000, 3);
|
2021-01-06 10:53:14 +00:00
|
|
|
select mapContains(a, b), mapContains(a, c), mapContains(a, 233) from table_map;
|
2021-09-22 17:31:49 +00:00
|
|
|
select mapContains(a, 'aaa') from table_map; -- { serverError 386 }
|
2021-01-06 10:53:14 +00:00
|
|
|
select mapContains(b, 'aaa') from table_map; -- { serverError 43 }
|
|
|
|
select mapKeys(a) from table_map;
|
2021-01-11 02:56:13 +00:00
|
|
|
select mapValues(a) from table_map;
|
2021-11-07 12:51:14 +00:00
|
|
|
select mapFromArrays(d, e) from table_map;
|
2021-01-06 10:53:14 +00:00
|
|
|
drop table if exists table_map;
|
2021-01-23 14:48:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
-- Const column
|
2021-01-23 14:53:08 +00:00
|
|
|
select map( 'aa', 4, 'bb' , 5) as m, mapKeys(m), mapValues(m);
|
2021-06-08 12:27:51 +00:00
|
|
|
select map( 'aa', 4, 'bb' , 5) as m, mapContains(m, 'aa'), mapContains(m, 'k');
|
|
|
|
|
|
|
|
select map(0, 0) as m, mapContains(m, number % 2) from numbers(2);
|
2021-11-07 12:20:35 +00:00
|
|
|
|
|
|
|
select mapFromArrays(['aa', 'bb'], [4, 5]);
|
2021-11-08 09:09:23 +00:00
|
|
|
select mapFromArrays(['aa', 'bb'], materialize([4, 5]));
|
|
|
|
select mapFromArrays(['aa', 'bb'], materialize([4, 5])) from numbers(3);
|
2021-11-07 12:20:35 +00:00
|
|
|
select mapFromArrays(['aa', 'bb'], [4, 5], [6, 7]); -- { serverError 42 }
|
|
|
|
select mapFromArrays(['aa', 'bb'], [4, 5, 6]); -- { serverError 190 }
|