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