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 | |
8 | namespace DB |
9 | { |
10 | |
11 | class FunctionFQDN : public IFunction |
12 | { |
13 | public: |
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 | |
45 | void registerFunctionFQDN(FunctionFactory & factory) |
46 | { |
47 | factory.registerFunction<FunctionFQDN>(FunctionFactory::CaseInsensitive); |
48 | factory.registerFunction<FunctionFQDN>("fullHostName"); |
49 | } |
50 | |
51 | } |
52 |