enable empty/notEmpty for map data type

This commit is contained in:
taiyang-li 2021-01-25 18:31:39 +08:00
parent f51c3ee9a3
commit 586def7fa3
3 changed files with 11 additions and 11 deletions

View File

@ -96,12 +96,6 @@ public:
}
else if (const ColumnMap* col_map = checkAndGetColumn<ColumnMap>(column.get()))
{
// only function length is implemented for ColumnMap
// TODO implemented other functions which use FunctionStringOrArrayToT
if (getName() != "length")
throw Exception("Illegal column " + arguments[0].column->getName() + " of argument of function " + getName(),
ErrorCodes::ILLEGAL_COLUMN);
auto col_res = ColumnVector<ResultType>::create();
typename ColumnVector<ResultType>::Container & vec_res = col_res->getData();
vec_res.resize(col_map->size());

View File

@ -1,2 +1,6 @@
2
2
0
0
1
1
0

View File

@ -1,6 +1,8 @@
set allow_experimental_map_type = 1;
drop table if exists table_map;
create table table_map (a Map(String, String)) engine = Memory;
insert into table_map values ({'name':'zhangsan', 'gender':'male'}), ({'name':'lisi', 'gender':'female'});
select length(a) from table_map;
select length(map(1,2,3,4));
select length(map());
select empty(map(1,2,3,4));
select empty(map());
select notEmpty(map(1,2,3,4));
select notEmpty(map());