ClickHouse/src/Functions/materialize.h

58 lines
1.4 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-06-29 14:54:32 +00:00
bool isInjective(const ColumnsWithTypeAndName & /*sample_columns*/) const override
{
return true;
}
2021-02-05 19:52:06 +00:00
bool useDefaultImplementationForLowCardinalityColumns() const override { return false; }
2021-06-22 16:21:23 +00:00
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) 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();
}
};
}