2019-12-09 13:12:54 +00:00
|
|
|
#include <Functions/IFunctionImpl.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";
|
|
|
|
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-17 21:41:50 +00:00
|
|
|
ColumnPtr executeImpl(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");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|