Fixed tests

This commit is contained in:
Maksim Kita 2021-04-22 00:19:01 +03:00
parent 631d870ae3
commit ddcffcb723
2 changed files with 18 additions and 23 deletions

View File

@ -361,6 +361,7 @@ inline bool isDecimal(const DataTypePtr & data_type) { return WhichDataType(data
inline bool isTuple(const DataTypePtr & data_type) { return WhichDataType(data_type).isTuple(); }
inline bool isArray(const DataTypePtr & data_type) { return WhichDataType(data_type).isArray(); }
inline bool isMap(const DataTypePtr & data_type) { return WhichDataType(data_type).isMap(); }
inline bool isNothing(const DataTypePtr & data_type) { return WhichDataType(data_type).isNothing(); }
template <typename T>
inline bool isUInt8(const T & data_type)

View File

@ -2496,7 +2496,7 @@ private:
}
}
WrapperType createArrayWrapper(const DataTypePtr & from_type_untyped, const DataTypeArray * to_type) const
WrapperType createArrayWrapper(const DataTypePtr & from_type_untyped, const DataTypeArray & to_type) const
{
/// Conversion from String through parsing.
if (checkAndGetDataType<DataTypeString>(from_type_untyped.get()))
@ -2507,27 +2507,23 @@ private:
};
}
DataTypePtr from_nested_type;
DataTypePtr to_nested_type;
const auto * from_type = checkAndGetDataType<DataTypeArray>(from_type_untyped.get());
/// get the most nested type
if (from_type && to_type)
if (!from_type)
{
from_nested_type = from_type->getNestedType();
to_nested_type = to_type->getNestedType();
throw Exception(ErrorCodes::TYPE_MISMATCH,
"CAST AS Array can only be perforamed between same-dimensional Array or String types");
}
if (from_type->getNumberOfDimensions() != to_type->getNumberOfDimensions())
{
WhichDataType from_nested_data_type(from_nested_type);
DataTypePtr from_nested_type = from_type->getNestedType();
/// In query SELECT CAST([] AS Array(Array(String))) from type is Array(Nothing)
bool is_empty_array = from_nested_data_type.isNothing();
if (!is_empty_array)
bool from_empty_array = isNothing(from_nested_type);
if (from_type->getNumberOfDimensions() != to_type.getNumberOfDimensions() && !from_empty_array)
throw Exception(ErrorCodes::TYPE_MISMATCH,
"CAST AS Array can only be performed between same-dimensional array types or from String");
}
}
"CAST AS Array can only be perforamed between same-dimensional array types");
const DataTypePtr & to_nested_type = to_type.getNestedType();
/// Prepare nested type conversion
const auto nested_function = prepareUnpackDictionaries(from_nested_type, to_nested_type);
@ -3093,14 +3089,12 @@ private:
return createStringWrapper(from_type);
case TypeIndex::FixedString:
return createFixedStringWrapper(from_type, checkAndGetDataType<DataTypeFixedString>(to_type.get())->getN());
case TypeIndex::Array:
return createArrayWrapper(from_type, checkAndGetDataType<DataTypeArray>(to_type.get()));
return createArrayWrapper(from_type, static_cast<const DataTypeArray &>(*to_type));
case TypeIndex::Tuple:
return createTupleWrapper(from_type, checkAndGetDataType<DataTypeTuple>(to_type.get()));
case TypeIndex::Map:
return createMapWrapper(from_type, checkAndGetDataType<DataTypeMap>(to_type.get()));
case TypeIndex::AggregateFunction:
return createAggregateFunctionWrapper(from_type, checkAndGetDataType<DataTypeAggregateFunction>(to_type.get()));
default: