From 329c9033a85a9aa011aff3a8b06977b7d5f94458 Mon Sep 17 00:00:00 2001 From: Anton Popov Date: Fri, 9 Apr 2021 20:50:10 +0300 Subject: [PATCH] fix conversion from const map with nulls --- src/Functions/FunctionsConversion.h | 8 ++++---- .../0_stateless/01803_const_nullable_map.reference | 1 + tests/queries/0_stateless/01803_const_nullable_map.sql | 9 +++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 tests/queries/0_stateless/01803_const_nullable_map.reference create mode 100644 tests/queries/0_stateless/01803_const_nullable_map.sql diff --git a/src/Functions/FunctionsConversion.h b/src/Functions/FunctionsConversion.h index 10aa1987559..c732ce5f931 100644 --- a/src/Functions/FunctionsConversion.h +++ b/src/Functions/FunctionsConversion.h @@ -2641,7 +2641,7 @@ private: WrapperType createMapToMapWrrapper(const DataTypes & from_kv_types, const DataTypes & to_kv_types) const { return [element_wrappers = getElementWrappers(from_kv_types, to_kv_types), from_kv_types, to_kv_types] - (ColumnsWithTypeAndName & arguments, const DataTypePtr &, const ColumnNullable * nullable_source, size_t input_rows_count) -> ColumnPtr + (ColumnsWithTypeAndName & arguments, const DataTypePtr &, const ColumnNullable * nullable_source, size_t /*input_rows_count*/) -> ColumnPtr { const auto * col = arguments.front().column.get(); const auto & column_map = typeid_cast(*col); @@ -2651,7 +2651,7 @@ private: for (size_t i = 0; i < 2; ++i) { ColumnsWithTypeAndName element = {{nested_data.getColumnPtr(i), from_kv_types[i], ""}}; - converted_columns[i] = element_wrappers[i](element, to_kv_types[i], nullable_source, input_rows_count); + converted_columns[i] = element_wrappers[i](element, to_kv_types[i], nullable_source, (element[0].column)->size()); } return ColumnMap::create(converted_columns[0], converted_columns[1], column_map.getNestedColumn().getOffsetsPtr()); @@ -2662,7 +2662,7 @@ private: WrapperType createArrayToMapWrrapper(const DataTypes & from_kv_types, const DataTypes & to_kv_types) const { return [element_wrappers = getElementWrappers(from_kv_types, to_kv_types), from_kv_types, to_kv_types] - (ColumnsWithTypeAndName & arguments, const DataTypePtr &, const ColumnNullable * nullable_source, size_t input_rows_count) -> ColumnPtr + (ColumnsWithTypeAndName & arguments, const DataTypePtr &, const ColumnNullable * nullable_source, size_t /*input_rows_count*/) -> ColumnPtr { const auto * col = arguments.front().column.get(); const auto & column_array = typeid_cast(*col); @@ -2672,7 +2672,7 @@ private: for (size_t i = 0; i < 2; ++i) { ColumnsWithTypeAndName element = {{nested_data.getColumnPtr(i), from_kv_types[i], ""}}; - converted_columns[i] = element_wrappers[i](element, to_kv_types[i], nullable_source, input_rows_count); + converted_columns[i] = element_wrappers[i](element, to_kv_types[i], nullable_source, (element[0].column)->size()); } return ColumnMap::create(converted_columns[0], converted_columns[1], column_array.getOffsetsPtr()); diff --git a/tests/queries/0_stateless/01803_const_nullable_map.reference b/tests/queries/0_stateless/01803_const_nullable_map.reference new file mode 100644 index 00000000000..573541ac970 --- /dev/null +++ b/tests/queries/0_stateless/01803_const_nullable_map.reference @@ -0,0 +1 @@ +0 diff --git a/tests/queries/0_stateless/01803_const_nullable_map.sql b/tests/queries/0_stateless/01803_const_nullable_map.sql new file mode 100644 index 00000000000..4ac9f925e24 --- /dev/null +++ b/tests/queries/0_stateless/01803_const_nullable_map.sql @@ -0,0 +1,9 @@ +DROP TABLE IF EXISTS t_map_null; + +SET allow_experimental_map_type = 1; + +CREATE TABLE t_map_null (a Map(String, String), b String) engine = MergeTree() ORDER BY a; +INSERT INTO t_map_null VALUES (map('a', 'b', 'c', 'd'), 'foo'); +SELECT count() FROM t_map_null WHERE a = map('name', NULL, '', NULL); + +DROP TABLE t_map_null;