ClickHouse/src/Functions/isNotDistinctFrom.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.7 KiB
C++
Raw Normal View History

#pragma once
#include <Functions/IFunction.h>
#include <Functions/FunctionFactory.h>
#include <DataTypes/DataTypesNumber.h>
#include <Interpreters/Context.h>
namespace DB
{
namespace ErrorCodes
{
2023-08-28 14:03:10 +00:00
extern const int NOT_IMPLEMENTED;
}
/**
* Performs null-safe comparison.
2023-08-31 15:22:27 +00:00
* equals(NULL, NULL) is NULL, while isNotDistinctFrom(NULL, NULL) is true.
* Currently, it can be used only in the JOIN ON section.
* This wrapper is needed to register function to make possible query analysis, syntax completion and so on.
*/
class FunctionIsNotDistinctFrom : public IFunction
{
public:
static constexpr auto name = "isNotDistinctFrom";
static FunctionPtr create(ContextPtr) { return std::make_shared<FunctionIsNotDistinctFrom>(); }
String getName() const override { return name; }
bool isVariadic() const override { return false; }
size_t getNumberOfArguments() const override { return 2; }
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; }
bool useDefaultImplementationForNulls() const override { return false; }
bool useDefaultImplementationForNothing() const override { return false; }
bool useDefaultImplementationForConstants() const override { return true; }
bool useDefaultImplementationForLowCardinalityColumns() const override { return true; }
2023-08-28 14:03:10 +00:00
DataTypePtr getReturnTypeImpl(const DataTypes &) const override { return std::make_shared<DataTypeUInt8>(); }
ColumnPtr executeImpl(const ColumnsWithTypeAndName & /* arguments */, const DataTypePtr &, size_t /* rows_count */) const override
{
2023-08-31 15:22:27 +00:00
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Function {} can be used only in the JOIN ON section", getName());
}
};
}