@@ -71,8 +71,9 @@ ColumnPtr ExecutableFunctionVariantAdaptor::executeImpl(
7171 DataTypePtr nested_result_type = func_base->getResultType ();
7272 ColumnPtr nested_result = func_base->execute (new_arguments, nested_result_type, variant_column.size (), dry_run);
7373
74- // / If result is Nullable(Nothing), just return column filled with NULLs.
75- if (nested_result_type->onlyNull ())
74+ // / If result is Nullable(Nothing) or Nothing, just return column filled with NULLs/defaults.
75+ // / Nothing can appear when the function is executed on an empty type (e.g. arrayElement on Array(Nothing)).
76+ if (nested_result_type->onlyNull () || isNothing (nested_result_type))
7677 {
7778 auto res = result_type->createColumn ();
7879 res->insertManyDefaults (variant_column.size ());
@@ -171,8 +172,8 @@ ColumnPtr ExecutableFunctionVariantAdaptor::executeImpl(
171172 ColumnPtr nested_result = func_base->execute (new_arguments, nested_result_type, new_arguments[0 ].column ->size (), dry_run)
172173 ->convertToFullColumnIfConst ();
173174
174- // / If result is Nullable(Nothing), just return column filled with NULLs.
175- if (nested_result_type->onlyNull ())
175+ // / If result is Nullable(Nothing) or Nothing , just return column filled with NULLs/defaults .
176+ if (nested_result_type->onlyNull () || isNothing (nested_result_type) )
176177 {
177178 auto res = result_type->createColumn ();
178179 res->insertManyDefaults (variant_column.size ());
@@ -348,8 +349,8 @@ ColumnPtr ExecutableFunctionVariantAdaptor::executeImpl(
348349
349350 variants_result_types[i] = nested_result_type;
350351
351- // / Set nullptr in case of only NULL values, we will insert NULL for rows of this selector.
352- if (nested_result_type->onlyNull ())
352+ // / Set nullptr in case of only NULL or Nothing values, we will insert NULL for rows of this selector.
353+ if (nested_result_type->onlyNull () || isNothing (nested_result_type) )
353354 {
354355 variants_results[i] = nullptr ;
355356 }
0 commit comments