mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-17 20:02:05 +00:00
Cast to array from empty array
This commit is contained in:
parent
3604aa92f8
commit
631d870ae3
@ -2517,14 +2517,17 @@ private:
|
|||||||
from_nested_type = from_type->getNestedType();
|
from_nested_type = from_type->getNestedType();
|
||||||
to_nested_type = to_type->getNestedType();
|
to_nested_type = to_type->getNestedType();
|
||||||
|
|
||||||
from_type = checkAndGetDataType<DataTypeArray>(from_nested_type.get());
|
if (from_type->getNumberOfDimensions() != to_type->getNumberOfDimensions())
|
||||||
to_type = checkAndGetDataType<DataTypeArray>(to_nested_type.get());
|
{
|
||||||
}
|
WhichDataType from_nested_data_type(from_nested_type);
|
||||||
|
|
||||||
/// both from_type and to_type should be nullptr now is array types had same dimensions
|
/// In query SELECT CAST([] AS Array(Array(String))) from type is Array(Nothing)
|
||||||
if ((from_type == nullptr) != (to_type == nullptr))
|
bool is_empty_array = from_nested_data_type.isNothing();
|
||||||
throw Exception{"CAST AS Array can only be performed between same-dimensional array types or from String",
|
if (!is_empty_array)
|
||||||
ErrorCodes::TYPE_MISMATCH};
|
throw Exception(ErrorCodes::TYPE_MISMATCH,
|
||||||
|
"CAST AS Array can only be performed between same-dimensional array types or from String");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Prepare nested type conversion
|
/// Prepare nested type conversion
|
||||||
const auto nested_function = prepareUnpackDictionaries(from_nested_type, to_nested_type);
|
const auto nested_function = prepareUnpackDictionaries(from_nested_type, to_nested_type);
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
[]
|
||||||
|
[]
|
@ -0,0 +1,2 @@
|
|||||||
|
SELECT CAST([] AS Array(Array(String)));
|
||||||
|
SELECT CAST([] AS Array(Array(Array(String))));
|
Loading…
Reference in New Issue
Block a user