Store only ColumnConst in ConstantValue

This commit is contained in:
Dmitry Novik 2024-05-02 18:16:55 +02:00
parent 054c5e3c80
commit ef4775c395

View File

@ -1,5 +1,6 @@
#pragma once
#include <Columns/ColumnConst.h>
#include <Columns/IColumn.h>
#include <Core/Field.h>
#include <DataTypes/IDataType.h>
@ -11,7 +12,7 @@ class ConstantValue
{
public:
ConstantValue(ColumnPtr column_, DataTypePtr data_type_)
: column(std::move(column_))
: column(wrapToColumnConst(column_))
, data_type(std::move(data_type_))
{}
@ -30,6 +31,14 @@ public:
return data_type;
}
private:
static ColumnPtr wrapToColumnConst(ColumnPtr column_)
{
if (!isColumnConst(*column_))
return ColumnConst::create(column_, 1);
return column_;
}
ColumnPtr column;
DataTypePtr data_type;
};