ClickHouse/src/Functions/FunctionFQDN.cpp

54 lines
1.3 KiB
C++
Raw Normal View History

2021-05-17 07:30:42 +00:00
#include <Functions/IFunction.h>
2019-10-12 07:17:30 +00:00
#include <Functions/FunctionFactory.h>
#include <DataTypes/DataTypeString.h>
2021-10-02 07:13:14 +00:00
#include <base/getFQDNOrHostName.h>
2019-10-12 07:17:30 +00:00
#include <Core/Field.h>
2019-12-29 01:13:17 +00:00
2019-10-12 07:17:30 +00:00
namespace DB
{
class FunctionFQDN : public IFunction
{
public:
static constexpr auto name = "FQDN";
2021-06-01 12:20:52 +00:00
static FunctionPtr create(ContextPtr)
2019-10-12 07:17:30 +00:00
{
return std::make_shared<FunctionFQDN>();
}
String getName() const override
{
return name;
}
bool isDeterministic() const override { return false; }
2021-06-22 16:21:23 +00:00
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; }
2019-10-12 07:17:30 +00:00
size_t getNumberOfArguments() const override
{
return 0;
}
DataTypePtr getReturnTypeImpl(const DataTypes & /*arguments*/) const override
{
return std::make_shared<DataTypeString>();
}
ColumnPtr executeImpl(const ColumnsWithTypeAndName &, const DataTypePtr & result_type, size_t input_rows_count) const override
2019-10-12 07:17:30 +00:00
{
2020-10-17 21:41:50 +00:00
return result_type->createColumnConst(
input_rows_count, getFQDNOrHostName())->convertToFullColumnIfConst();
2019-10-12 07:17:30 +00:00
}
};
void registerFunctionFQDN(FunctionFactory & factory)
{
factory.registerFunction<FunctionFQDN>(FunctionFactory::CaseInsensitive);
factory.registerFunction<FunctionFQDN>("fullHostName");
}
}