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>
|
2020-03-18 18:54:27 +00:00
|
|
|
#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";
|
2021-04-10 23:33:54 +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; }
|
|
|
|
|
|
|
|
size_t getNumberOfArguments() const override
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DataTypePtr getReturnTypeImpl(const DataTypes & /*arguments*/) const override
|
|
|
|
{
|
|
|
|
return std::make_shared<DataTypeString>();
|
|
|
|
}
|
|
|
|
|
2020-11-17 13:24:45 +00:00
|
|
|
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(
|
2019-10-12 09:21:30 +00:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|