1#include <Functions/IFunctionImpl.h>
2#include <Functions/FunctionFactory.h>
3#include <DataTypes/DataTypeString.h>
4#include <Common/getFQDNOrHostName.h>
5#include <Core/Field.h>
6
7
8namespace DB
9{
10
11class FunctionFQDN : public IFunction
12{
13public:
14 static constexpr auto name = "FQDN";
15 static FunctionPtr create(const Context &)
16 {
17 return std::make_shared<FunctionFQDN>();
18 }
19
20 String getName() const override
21 {
22 return name;
23 }
24
25 bool isDeterministic() const override { return false; }
26
27 size_t getNumberOfArguments() const override
28 {
29 return 0;
30 }
31
32 DataTypePtr getReturnTypeImpl(const DataTypes & /*arguments*/) const override
33 {
34 return std::make_shared<DataTypeString>();
35 }
36
37 void executeImpl(Block & block, const ColumnNumbers &, size_t result, size_t input_rows_count) override
38 {
39 block.getByPosition(result).column = block.getByPosition(result).type->createColumnConst(
40 input_rows_count, getFQDNOrHostName())->convertToFullColumnIfConst();
41 }
42};
43
44
45void registerFunctionFQDN(FunctionFactory & factory)
46{
47 factory.registerFunction<FunctionFQDN>(FunctionFactory::CaseInsensitive);
48 factory.registerFunction<FunctionFQDN>("fullHostName");
49}
50
51}
52