提交 57104f81 编写于 作者: L Léo Ercolanelli

rename `widen` to `promote` for IDataType

上级 0d6094a3
......@@ -72,7 +72,7 @@ public:
types.emplace_back(std::make_shared<DataTypeArray>(keys_type));
for (const auto & value_type : values_types)
types.emplace_back(std::make_shared<DataTypeArray>(widenDataType(value_type)));
types.emplace_back(std::make_shared<DataTypeArray>(promoteNumericType(value_type)));
return std::make_shared<DataTypeTuple>(types);
}
......@@ -262,13 +262,13 @@ public:
bool keepKey(const T & key) const { return static_cast<const Derived &>(*this).keepKey(key); }
private:
static DataTypePtr widenDataType(const DataTypePtr & data_type)
static DataTypePtr promoteNumericType(const DataTypePtr & data_type)
{
if (!data_type->canBeWiden())
if (!data_type->canBePromoted())
throw new Exception{"Values to be summed are expected to be Numeric, Float or Decimal.",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
return data_type->getWidenDataType();
return data_type->promoteNumericType();
}
};
......
......@@ -412,7 +412,7 @@ namespace ErrorCodes
extern const int NO_DATA_FOR_REQUIRED_PROTOBUF_FIELD = 435;
extern const int CANNOT_CONVERT_TO_PROTOBUF_TYPE = 436;
extern const int PROTOBUF_FIELD_NOT_REPEATED = 437;
extern const int DATA_TYPE_CANNOT_BE_WIDEN = 438;
extern const int DATA_TYPE_CANNOT_BE_PROMOTED = 438;
extern const int KEEPER_EXCEPTION = 999;
extern const int POCO_EXCEPTION = 1000;
......
......@@ -149,10 +149,10 @@ Field DataTypeDecimal<T>::getDefault() const
template <typename T>
DataTypePtr DataTypeDecimal<T>::getWidenDataType() const
DataTypePtr DataTypeDecimal<T>::promoteNumericType() const
{
using WidenDataType = DataTypeDecimal<Decimal128>;
return std::make_shared<WidenDataType>(WidenDataType::maxPrecision(), scale);
using PromotedType = DataTypeDecimal<Decimal128>;
return std::make_shared<PromotedType>(PromotedType::maxPrecision(), scale);
}
......
......@@ -103,8 +103,8 @@ public:
void serializeProtobuf(const IColumn & column, size_t row_num, ProtobufWriter & protobuf) const override;
Field getDefault() const override;
bool canBeWiden() const override { return true; }
DataTypePtr getWidenDataType() const override;
bool canBePromoted() const override { return true; }
DataTypePtr promoteNumericType() const override;
MutableColumnPtr createColumn() const override;
bool equals(const IDataType & rhs) const override;
......
......@@ -18,11 +18,11 @@ class DataTypeNumber final : public DataTypeNumberBase<T>
bool canBeUsedInBooleanContext() const override { return true; }
bool canBeInsideNullable() const override { return true; }
bool canBeWiden() const override { return true; }
DataTypePtr getWidenDataType() const override
bool canBePromoted() const override { return true; }
DataTypePtr promoteNumericType() const override
{
using WidenDataType = DataTypeNumber<NearestFieldType<T>>;
return std::make_shared<WidenDataType>();
using PromotedType = DataTypeNumber<NearestFieldType<T>>;
return std::make_shared<PromotedType>();
}
};
......
......@@ -19,7 +19,7 @@ namespace ErrorCodes
{
extern const int MULTIPLE_STREAMS_REQUIRED;
extern const int LOGICAL_ERROR;
extern const int DATA_TYPE_CANNOT_BE_WIDEN;
extern const int DATA_TYPE_CANNOT_BE_PROMOTED;
}
......@@ -52,9 +52,9 @@ ColumnPtr IDataType::createColumnConstWithDefaultValue(size_t size) const
return createColumnConst(size, getDefault());
}
DataTypePtr IDataType::getWidenDataType() const
DataTypePtr IDataType::promoteNumericType() const
{
throw Exception("Data type " + getName() + " can't be widen.", ErrorCodes::DATA_TYPE_CANNOT_BE_WIDEN);
throw Exception("Data type " + getName() + " can't be promoted.", ErrorCodes::DATA_TYPE_CANNOT_BE_PROMOTED);
}
void IDataType::serializeBinaryBulk(const IColumn &, WriteBuffer &, size_t, size_t) const
......
......@@ -273,14 +273,14 @@ public:
*/
virtual Field getDefault() const = 0;
/** The data type can be widen in order to try to avoid overflows.
* Widenable data types are typically Number or Decimal data types.
/** The data type can be promoted in order to try to avoid overflows.
* Data types which can be promoted are typically Number or Decimal data types.
*/
virtual bool canBeWiden() const { return false; }
virtual bool canBePromoted() const { return false; }
/** Return the widen data type of the current data type. Throw an exception if `canBeWiden() == false`.
/** Return the promoted numeric data type of the current data type. Throw an exception if `canBePromoted() == false`.
*/
virtual DataTypePtr getWidenDataType() const;
virtual DataTypePtr promoteNumericType() const;
/** Directly insert default value into a column. Default implementation use method IColumn::insertDefault.
* This should be overriden if data type default value differs from column default value (example: Enum data types).
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册