From 586def7fa35175072fa444cb2ace91fa9f7fb450 Mon Sep 17 00:00:00 2001 From: taiyang-li Date: Mon, 25 Jan 2021 18:31:39 +0800 Subject: [PATCH] enable empty/notEmpty for map data type --- src/Functions/FunctionStringOrArrayToT.h | 6 ------ tests/queries/0_stateless/01592_length_map.reference | 6 +++++- tests/queries/0_stateless/01592_length_map.sql | 10 ++++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Functions/FunctionStringOrArrayToT.h b/src/Functions/FunctionStringOrArrayToT.h index 2108fa7e8b6..efbfec2aba1 100644 --- a/src/Functions/FunctionStringOrArrayToT.h +++ b/src/Functions/FunctionStringOrArrayToT.h @@ -96,12 +96,6 @@ public: } else if (const ColumnMap* col_map = checkAndGetColumn(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::create(); typename ColumnVector::Container & vec_res = col_res->getData(); vec_res.resize(col_map->size()); diff --git a/tests/queries/0_stateless/01592_length_map.reference b/tests/queries/0_stateless/01592_length_map.reference index 51993f072d5..ae0a0551df9 100644 --- a/tests/queries/0_stateless/01592_length_map.reference +++ b/tests/queries/0_stateless/01592_length_map.reference @@ -1,2 +1,6 @@ 2 -2 +0 +0 +1 +1 +0 diff --git a/tests/queries/0_stateless/01592_length_map.sql b/tests/queries/0_stateless/01592_length_map.sql index 4f2b0737d82..368029a5aac 100644 --- a/tests/queries/0_stateless/01592_length_map.sql +++ b/tests/queries/0_stateless/01592_length_map.sql @@ -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()); \ No newline at end of file