materialize.h 1.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#pragma once
#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>

namespace DB
{

/** materialize(x) - materialize the constant
  */
class FunctionMaterialize : public IFunction
{
public:
    static constexpr auto name = "materialize";
    static FunctionPtr create(const Context &)
    {
        return std::make_shared<FunctionMaterialize>();
    }

    bool useDefaultImplementationForNulls() const override
    {
        return false;
    }

    /// Get the function name.
    String getName() const override
    {
        return name;
    }

N
Nikolai Kochetov 已提交
30 31
    bool useDefaultImplementationForLowCardinalityColumns() const override { return false; }

32 33 34 35 36 37 38 39 40 41
    size_t getNumberOfArguments() const override
    {
        return 1;
    }

    DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
    {
        return arguments[0];
    }

42
    ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr &, size_t /*input_rows_count*/) const override
43 44 45 46 47 48
    {
        return arguments[0].column->convertToFullColumnIfConst();
    }
};

}