mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Make result Bool only if arguments contain Bool
This commit is contained in:
parent
ba54a5ff80
commit
2d975057d0
@ -484,10 +484,14 @@ DataTypePtr FunctionAnyArityLogical<Impl, Name>::getReturnTypeImpl(const DataTyp
|
||||
ErrorCodes::TOO_FEW_ARGUMENTS_FOR_FUNCTION);
|
||||
|
||||
bool has_nullable_arguments = false;
|
||||
bool has_bool_arguments = false;
|
||||
for (size_t i = 0; i < arguments.size(); ++i)
|
||||
{
|
||||
const auto & arg_type = arguments[i];
|
||||
|
||||
if (isBool(arg_type))
|
||||
has_bool_arguments = true;
|
||||
|
||||
if (!has_nullable_arguments)
|
||||
{
|
||||
has_nullable_arguments = arg_type->isNullable();
|
||||
@ -504,7 +508,7 @@ DataTypePtr FunctionAnyArityLogical<Impl, Name>::getReturnTypeImpl(const DataTyp
|
||||
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
||||
}
|
||||
|
||||
auto result_type = DataTypeFactory::instance().get("Bool");
|
||||
auto result_type = has_bool_arguments ? DataTypeFactory::instance().get("Bool") : std::make_shared<DataTypeUInt8>();
|
||||
return has_nullable_arguments
|
||||
? makeNullable(result_type)
|
||||
: result_type;
|
||||
@ -712,7 +716,7 @@ DataTypePtr FunctionUnaryLogical<Impl, Name>::getReturnTypeImpl(const DataTypes
|
||||
+ ") of argument of function " + getName(),
|
||||
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
||||
|
||||
return DataTypeFactory::instance().get("Bool");
|
||||
return isBool(arguments[0]) ? DataTypeFactory::instance().get("Bool") : std::make_shared<DataTypeUInt8>();
|
||||
}
|
||||
|
||||
template <template <typename> class Impl, typename T>
|
||||
|
@ -1,36 +1,36 @@
|
||||
Bool
|
||||
Bool
|
||||
true
|
||||
0
|
||||
1
|
||||
0
|
||||
Bool
|
||||
UInt8
|
||||
UInt8
|
||||
UInt8
|
||||
false
|
||||
1
|
||||
0
|
||||
true
|
||||
Bool
|
||||
UInt8
|
||||
UInt8
|
||||
Bool
|
||||
true
|
||||
0
|
||||
1
|
||||
false
|
||||
Bool
|
||||
Bool
|
||||
Bool
|
||||
Bool
|
||||
false
|
||||
true
|
||||
false
|
||||
true
|
||||
Bool
|
||||
Bool
|
||||
Bool
|
||||
UInt8
|
||||
UInt8
|
||||
Bool
|
||||
true
|
||||
false
|
||||
true
|
||||
false
|
||||
Bool
|
||||
Bool
|
||||
Bool
|
||||
Bool
|
||||
true
|
||||
true
|
||||
true
|
||||
1
|
||||
1
|
||||
true
|
||||
Bool
|
||||
Bool
|
||||
Bool
|
||||
UInt8
|
||||
UInt8
|
||||
Bool
|
||||
true
|
||||
false
|
||||
|
Loading…
Reference in New Issue
Block a user