From e123c6ef9dde3c009535f97fff21e36032c3e0c3 Mon Sep 17 00:00:00 2001 From: hexiaoting Date: Tue, 23 Feb 2021 18:42:33 +0800 Subject: [PATCH] Bug fix: Tuple cast to Map --- src/Functions/FunctionsConversion.h | 4 ++-- .../0_stateless/01744_tuple_cast_to_map_bugfix.reference | 3 +++ tests/queries/0_stateless/01744_tuple_cast_to_map_bugfix.sql | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 tests/queries/0_stateless/01744_tuple_cast_to_map_bugfix.reference create mode 100644 tests/queries/0_stateless/01744_tuple_cast_to_map_bugfix.sql diff --git a/src/Functions/FunctionsConversion.h b/src/Functions/FunctionsConversion.h index 2e2a4ce9cfa..4889132eeb2 100644 --- a/src/Functions/FunctionsConversion.h +++ b/src/Functions/FunctionsConversion.h @@ -2586,7 +2586,7 @@ private: WrapperType createTupleToMapWrapper(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_tuple = assert_cast(*col); @@ -2597,7 +2597,7 @@ private: { const auto & column_array = assert_cast(column_tuple.getColumn(i)); ColumnsWithTypeAndName element = {{column_array.getDataPtr(), 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()); offsets[i] = column_array.getOffsetsPtr(); } diff --git a/tests/queries/0_stateless/01744_tuple_cast_to_map_bugfix.reference b/tests/queries/0_stateless/01744_tuple_cast_to_map_bugfix.reference new file mode 100644 index 00000000000..c5143f7c4e9 --- /dev/null +++ b/tests/queries/0_stateless/01744_tuple_cast_to_map_bugfix.reference @@ -0,0 +1,3 @@ +{1:'Ready',2:'Steady',3:'Go'} +{1:'Ready',2:'Steady',3:'Go'} +{1:'Ready',2:'Steady',3:'Go'} diff --git a/tests/queries/0_stateless/01744_tuple_cast_to_map_bugfix.sql b/tests/queries/0_stateless/01744_tuple_cast_to_map_bugfix.sql new file mode 100644 index 00000000000..c5c50c5b039 --- /dev/null +++ b/tests/queries/0_stateless/01744_tuple_cast_to_map_bugfix.sql @@ -0,0 +1,3 @@ +SELECT CAST((['1', '2', '3'], ['Ready', 'Steady', 'Go']), 'Map(UInt8, String)') AS map; +SELECT CAST((['1', '2', '3'], ['Ready', 'Steady', 'Go']), 'Map(UInt8, String)') AS map; +SELECT CAST((['1', '2', '3'], ['Ready', 'Steady', 'Go']), 'Map(UInt8, String)') AS map;