mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 01:22:04 +00:00
Merge pull request #6297 from 4ertus2/bugs
Fix crash on CAST exotic types to Decimal
This commit is contained in:
commit
12a8bf20eb
@ -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