mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
fix crash on CAST exotic types to decimal
This commit is contained in:
parent
7015e5ca7d
commit
fcc6a2c2be
@ -463,9 +463,8 @@ struct WhichDataType
|
||||
{
|
||||
TypeIndex idx;
|
||||
|
||||
/// For late initialization.
|
||||
WhichDataType()
|
||||
: idx(TypeIndex::Nothing)
|
||||
WhichDataType(TypeIndex idx_ = TypeIndex::Nothing)
|
||||
: idx(idx_)
|
||||
{}
|
||||
|
||||
WhichDataType(const IDataType & data_type)
|
||||
|
@ -1634,6 +1634,17 @@ private:
|
||||
TypeIndex type_index = from_type->getTypeId();
|
||||
UInt32 scale = to_type->getScale();
|
||||
|
||||
WhichDataType which(type_index);
|
||||
bool ok = which.isNativeInt() ||
|
||||
which.isNativeUInt() ||
|
||||
which.isDecimal() ||
|
||||
which.isFloat() ||
|
||||
which.isDateOrDateTime() ||
|
||||
which.isStringOrFixedString();
|
||||
if (!ok)
|
||||
throw Exception{"Conversion from " + from_type->getName() + " to " + to_type->getName() + " is not supported",
|
||||
ErrorCodes::CANNOT_CONVERT_TYPE};
|
||||
|
||||
return [type_index, scale] (Block & block, const ColumnNumbers & arguments, const size_t result, size_t input_rows_count)
|
||||
{
|
||||
callOnIndexAndDataType<ToDataType>(type_index, [&](const auto & types) -> bool
|
||||
|
@ -0,0 +1 @@
|
||||
select cast(toIntervalDay(1) as Nullable(Decimal(10, 10))); -- { serverError 70 }
|
Loading…
Reference in New Issue
Block a user