mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Remove weird special case in if() return type inference, to match multiIf()
This commit is contained in:
parent
059f1abcf6
commit
c1ea1726b4
@ -147,7 +147,7 @@ private:
|
||||
continue;
|
||||
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR,
|
||||
"Function {} expects {} argument to have {} type but receives {} after running {} pass",
|
||||
"Function {} expects argument {} to have {} type but receives {} after running {} pass",
|
||||
function->toAST()->formatForErrorMessage(),
|
||||
i + 1,
|
||||
expected_argument_type->getName(),
|
||||
|
@ -1278,16 +1278,16 @@ public:
|
||||
/// Get result types by argument types. If the function does not apply to these arguments, throw an exception.
|
||||
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
|
||||
{
|
||||
if (arguments[0]->onlyNull())
|
||||
return arguments[2];
|
||||
if (!arguments[0]->onlyNull())
|
||||
{
|
||||
if (arguments[0]->isNullable())
|
||||
return getReturnTypeImpl({
|
||||
removeNullable(arguments[0]), arguments[1], arguments[2]});
|
||||
|
||||
if (arguments[0]->isNullable())
|
||||
return getReturnTypeImpl({
|
||||
removeNullable(arguments[0]), arguments[1], arguments[2]});
|
||||
|
||||
if (!WhichDataType(arguments[0]).isUInt8())
|
||||
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of first argument (condition) of function if. "
|
||||
"Must be UInt8.", arguments[0]->getName());
|
||||
if (!WhichDataType(arguments[0]).isUInt8())
|
||||
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of first argument (condition) of function if. "
|
||||
"Must be UInt8.", arguments[0]->getName());
|
||||
}
|
||||
|
||||
if (use_variant_when_no_common_type)
|
||||
return getLeastSupertypeOrVariant(DataTypes{arguments[1], arguments[2]});
|
||||
|
Loading…
Reference in New Issue
Block a user