Merge pull request #19515 from hexiaoting/map_functions_fix

Bug fix : support const column processing in mapContains, mapKeys, mapValues functions
This commit is contained in:
Anton Popov 2021-01-25 17:30:59 +03:00 committed by GitHub
commit f203a33a8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 0 deletions

View File

@ -177,6 +177,8 @@ public:
return std::make_shared<DataTypeUInt8>();
}
bool useDefaultImplementationForConstants() const override { return true; }
ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr & result_type, size_t input_rows_count) const override
{
const ColumnMap * col_map = typeid_cast<const ColumnMap *>(arguments[0].column.get());
@ -233,6 +235,8 @@ public:
return std::make_shared<DataTypeArray>(key_type);
}
bool useDefaultImplementationForConstants() const override { return true; }
ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr & /*result_type*/, size_t /*input_rows_count*/) const override
{
const ColumnMap * col_map = typeid_cast<const ColumnMap *>(arguments[0].column.get());
@ -278,6 +282,8 @@ public:
return std::make_shared<DataTypeArray>(value_type);
}
bool useDefaultImplementationForConstants() const override { return true; }
ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr & /*result_type*/, size_t /*input_rows_count*/) const override
{
const ColumnMap * col_map = typeid_cast<const ColumnMap *>(arguments[0].column.get());

View File

@ -17,3 +17,5 @@
[1000]
[1001]
[1002]
{'aa':4,'bb':5} ['aa','bb'] [4,5]
{'aa':4,'bb':5} 1 0

View File

@ -20,3 +20,8 @@ select mapContains(b, 'aaa') from table_map; -- { serverError 43 }
select mapKeys(a) from table_map;
select mapValues(a) from table_map;
drop table if exists table_map;
-- Const column
select map( 'aa', 4, 'bb' , 5) as m, mapKeys(m), mapValues(m);
select map( 'aa', 4, 'bb' , 5) as m, mapContains(m, 'aa'), mapContains(m, 'k');