mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-20 14:42:02 +00:00
feat(Function): isNullable
This commit is contained in:
parent
1f2266e45f
commit
849c46e6fa
60
src/Functions/isNullable.cpp
Normal file
60
src/Functions/isNullable.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
#include <Functions/IFunction.h>
|
||||
#include <Functions/FunctionFactory.h>
|
||||
#include <DataTypes/DataTypesNumber.h>
|
||||
#include <Columns/ColumnsNumber.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
namespace
|
||||
{
|
||||
|
||||
class FunctionIsNullable : public IFunction
|
||||
{
|
||||
public:
|
||||
static constexpr auto name = "isNullable";
|
||||
static FunctionPtr create(ContextPtr)
|
||||
{
|
||||
return std::make_shared<FunctionIsNullable>();
|
||||
}
|
||||
|
||||
String getName() const override
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
bool useDefaultImplementationForNulls() const override { return false; }
|
||||
|
||||
bool useDefaultImplementationForNothing() const override { return false; }
|
||||
|
||||
bool useDefaultImplementationForConstants() const override { return true; }
|
||||
|
||||
ColumnNumbers getArgumentsThatDontImplyNullableReturnType(size_t /*number_of_arguments*/) const override { return {0}; }
|
||||
|
||||
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; }
|
||||
|
||||
size_t getNumberOfArguments() const override
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
DataTypePtr getReturnTypeImpl(const DataTypes & /*arguments*/) const override
|
||||
{
|
||||
return std::make_shared<DataTypeUInt8>();
|
||||
}
|
||||
|
||||
ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr &, size_t input_rows_count) const override
|
||||
{
|
||||
const auto & elem = arguments[0];
|
||||
return ColumnUInt8::create(input_rows_count, isColumnNullable(*elem.column));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
void registerFunctionIsNullable(FunctionFactory & factory)
|
||||
{
|
||||
factory.registerFunction<FunctionIsNullable>();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ void registerFunctionNullIf(FunctionFactory & factory);
|
||||
void registerFunctionAssumeNotNull(FunctionFactory & factory);
|
||||
void registerFunctionToNullable(FunctionFactory & factory);
|
||||
void registerFunctionIsZeroOrNull(FunctionFactory & factory);
|
||||
void registerFunctionIsNullable(FunctionFactory & factory);
|
||||
|
||||
|
||||
void registerFunctionsNull(FunctionFactory & factory)
|
||||
@ -23,6 +24,7 @@ void registerFunctionsNull(FunctionFactory & factory)
|
||||
registerFunctionAssumeNotNull(factory);
|
||||
registerFunctionToNullable(factory);
|
||||
registerFunctionIsZeroOrNull(factory);
|
||||
registerFunctionIsNullable(factory);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user