1 | #include <Functions/IFunctionImpl.h> |
---|---|
2 | #include <Functions/FunctionFactory.h> |
3 | |
4 | |
5 | namespace DB |
6 | { |
7 | |
8 | class FunctionIdentity : public IFunction |
9 | { |
10 | public: |
11 | static constexpr auto name = "identity"; |
12 | static FunctionPtr create(const Context &) |
13 | { |
14 | return std::make_shared<FunctionIdentity>(); |
15 | } |
16 | |
17 | String getName() const override |
18 | { |
19 | return name; |
20 | } |
21 | |
22 | size_t getNumberOfArguments() const override |
23 | { |
24 | return 1; |
25 | } |
26 | |
27 | DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override |
28 | { |
29 | return arguments.front(); |
30 | } |
31 | |
32 | void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result, size_t /*input_rows_count*/) override |
33 | { |
34 | block.getByPosition(result).column = block.getByPosition(arguments.front()).column; |
35 | } |
36 | }; |
37 | |
38 | |
39 | void registerFunctionIdentity(FunctionFactory & factory) |
40 | { |
41 | factory.registerFunction<FunctionIdentity>(); |
42 | } |
43 | |
44 | } |
45 |