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>
|
2021-05-15 11:39:13 +00:00
|
|
|
#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";
|
2021-04-10 23:33:54 +00:00
|
|
|
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];
|
|
|
|
}
|
|
|
|
|
2020-11-21 10:54:50 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|