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-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; }
|
2024-03-19 10:41:23 +00:00
|
|
|
|
|
|
|
bool isSuitableForConstantFolding() const override { return false; }
|
2021-02-05 19:52:06 +00:00
|
|
|
|
2021-06-22 16:21:23 +00:00
|
|
|
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; }
|
2021-04-29 14:48:26 +00:00
|
|
|
|
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();
|
|
|
|
}
|
2023-09-14 10:41:43 +00:00
|
|
|
|
|
|
|
bool hasInformationAboutMonotonicity() const override { return true; }
|
|
|
|
|
|
|
|
Monotonicity getMonotonicityForRange(const IDataType &, const Field &, const Field &) const override
|
|
|
|
{
|
|
|
|
/// Depending on the argument the function materialize() is either a constant or works as identity().
|
|
|
|
/// In both cases this function is monotonic and non-decreasing.
|
|
|
|
return {.is_monotonic = true, .is_always_monotonic = true};
|
|
|
|
}
|
2020-11-17 19:43:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|