#include #include #include namespace DB { UInt32 extractToDecimalScale(const ColumnWithTypeAndName & named_column) { const auto * arg_type = named_column.type.get(); bool ok = checkAndGetDataType(arg_type) || checkAndGetDataType(arg_type) || checkAndGetDataType(arg_type) || checkAndGetDataType(arg_type); if (!ok) throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type of toDecimal() scale {}", named_column.type->getName()); Field field; named_column.column->get(0, field); return static_cast(field.get()); } FunctionOverloadResolverPtr createInternalCastOverloadResolver(CastType type, std::optional diagnostic) { switch (type) { case CastType::nonAccurate: return CastInternalOverloadResolver::createImpl(diagnostic); case CastType::accurate: return CastInternalOverloadResolver::createImpl(diagnostic); case CastType::accurateOrNull: return CastInternalOverloadResolver::createImpl(diagnostic); } } REGISTER_FUNCTION(CastOverloadResolvers) { factory.registerFunction>({}, FunctionFactory::CaseInsensitive); /// Note: "internal" (not affected by null preserving setting) versions of accurate cast functions are unneeded. factory.registerFunction>({}, FunctionFactory::CaseInsensitive); factory.registerFunction>(); factory.registerFunction>(); } }