ClickHouse/src/Functions/FunctionFQDN.cpp

52 lines
1.2 KiB
C++
Raw Normal View History

#include <Functions/IFunctionImpl.h>
2019-10-12 07:17:30 +00:00
#include <Functions/FunctionFactory.h>
#include <DataTypes/DataTypeString.h>
#include <common/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";
static FunctionPtr create(const Context &)
{
return std::make_shared<FunctionFQDN>();
}
String getName() const override
{
return name;
}
bool isDeterministic() const override { return false; }
size_t getNumberOfArguments() const override
{
return 0;
}
DataTypePtr getReturnTypeImpl(const DataTypes & /*arguments*/) const override
{
return std::make_shared<DataTypeString>();
}
2020-10-14 14:04:50 +00:00
void executeImpl(ColumnsWithTypeAndName & columns, const ColumnNumbers &, size_t result, size_t input_rows_count) const override
2019-10-12 07:17:30 +00:00
{
2020-10-14 14:04:50 +00:00
columns[result].column = columns[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");
}
}