fix arrayMap with array of tuples with single argument

This commit is contained in:
Anton Popov 2023-05-11 14:52:01 +00:00
parent 99677f3d1a
commit 84aa97b738
3 changed files with 12 additions and 3 deletions

View File

@ -135,7 +135,7 @@ public:
size_t num_function_arguments = function_type->getArgumentTypes().size();
if (is_single_array_argument
&& tuple_argument_size
&& tuple_argument_size > 1
&& tuple_argument_size == num_function_arguments)
{
assert(nested_types.size() == 1);
@ -337,12 +337,13 @@ public:
}
const auto * column_tuple = checkAndGetColumn<ColumnTuple>(&column_array->getData());
if (is_single_array_argument && column_tuple && column_tuple->getColumns().size() == num_function_arguments)
size_t tuple_size = column_tuple ? column_tuple->getColumns().size() : 0;
if (is_single_array_argument && tuple_size > 1 && tuple_size == num_function_arguments)
{
const auto & type_tuple = assert_cast<const DataTypeTuple &>(*array_type->getNestedType());
const auto & tuple_names = type_tuple.getElementNames();
size_t tuple_size = column_tuple->getColumns().size();
arrays.reserve(column_tuple->getColumns().size());
for (size_t j = 0; j < tuple_size; ++j)
{

View File

@ -0,0 +1,4 @@
[(1)]
[1]
[3]
[3]

View File

@ -0,0 +1,4 @@
SELECT arrayMap((x) -> x, [tuple(1)]);
SELECT arrayMap((x) -> x.1, [tuple(1)]);
SELECT arrayMap((x) -> x.1 + x.2, [tuple(1, 2)]);
SELECT arrayMap((x, y) -> x + y, [tuple(1, 2)]);