ClickHouse/src/Functions/materialize.h

51 lines
1.1 KiB
C++
Raw Normal View History

2020-11-17 19:43:26 +00:00
#pragma once
2021-05-17 07:30:42 +00:00
#include <Functions/IFunction.h>
2020-11-17 19:43:26 +00:00
#include <Functions/FunctionFactory.h>
#include <Columns/ColumnLowCardinality.h>
#include <DataTypes/DataTypeLowCardinality.h>
2020-11-17 19:43:26 +00:00
namespace DB
{
/** materialize(x) - materialize the constant
*/
class FunctionMaterialize : public IFunction
{
public:
static constexpr auto name = "materialize";
static FunctionPtr create(ContextPtr)
2020-11-17 19:43:26 +00:00
{
return std::make_shared<FunctionMaterialize>();
}
bool useDefaultImplementationForNulls() const override
{
return false;
}
/// Get the function name.
String getName() const override
{
return name;
}
2021-02-05 19:52:06 +00:00
bool useDefaultImplementationForLowCardinalityColumns() const override { return false; }
2020-11-17 19:43:26 +00:00
size_t getNumberOfArguments() const override
{
return 1;
}
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
{
return arguments[0];
}
ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr &, size_t /*input_rows_count*/) const override
2020-11-17 19:43:26 +00:00
{
return arguments[0].column->convertToFullColumnIfConst();
}
};
}