mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-11 00:42:29 +00:00
Fix Illegal column Nothing while using arrayMap
This commit is contained in:
parent
db06b98027
commit
cbada6fe03
@ -275,6 +275,11 @@ ColumnPtr IExecutableFunction::executeWithoutSparseColumns(const ColumnsWithType
|
||||
|
||||
ColumnPtr IExecutableFunction::execute(const ColumnsWithTypeAndName & arguments, const DataTypePtr & result_type, size_t input_rows_count, bool dry_run) const
|
||||
{
|
||||
/// Result type Nothing means that we don't need to execute function at all.
|
||||
/// Example: select arrayMap(x -> 2 * x, []);
|
||||
if (isNothing(result_type))
|
||||
return result_type->createColumn();
|
||||
|
||||
if (useDefaultImplementationForSparseColumns())
|
||||
{
|
||||
size_t num_sparse_columns = 0;
|
||||
@ -430,6 +435,15 @@ DataTypePtr IFunctionOverloadResolver::getReturnTypeWithoutLowCardinality(const
|
||||
}
|
||||
}
|
||||
|
||||
/// If one of the arguments is Nothing, then we won't really execute
|
||||
/// the function and the result type should be also Nothing.
|
||||
/// Example: select arrayMap(x -> 2 * x, []);
|
||||
for (const auto & arg : arguments)
|
||||
{
|
||||
if (isNothing(arg.type))
|
||||
return std::make_shared<DataTypeNothing>();
|
||||
}
|
||||
|
||||
return getReturnTypeImpl(arguments);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,6 @@
|
||||
[]
|
||||
Array(Nothing)
|
||||
[]
|
||||
Array(Nothing)
|
||||
[]
|
||||
Array(Nothing)
|
@ -0,0 +1,6 @@
|
||||
select arrayMap(x -> 2 * x, []);
|
||||
select toTypeName(arrayMap(x -> 2 * x, []));
|
||||
select arrayMap((x, y) -> x + y, [], []);
|
||||
select toTypeName(arrayMap((x, y) -> x + y, [], []));
|
||||
select arrayMap((x, y) -> x + y, [], CAST([], 'Array(Int32)'));
|
||||
select toTypeName(arrayMap((x, y) -> x + y, [], CAST([], 'Array(Int32)')));
|
Loading…
Reference in New Issue
Block a user