move IColumn.isColumnConst() outside of interface

This commit is contained in:
chertus 2019-06-27 22:28:52 +03:00
parent db7c8748e9
commit f19dee706a
54 changed files with 100 additions and 95 deletions

View File

@ -102,4 +102,9 @@ void ColumnConst::getPermutation(bool /*reverse*/, size_t /*limit*/, int /*nan_d
res[i] = i;
}
bool isColumnConst(const IColumn & column)
{
return checkColumn<ColumnConst>(column);
}
}

View File

@ -198,7 +198,6 @@ public:
}
bool onlyNull() const override { return data->isNullAt(0); }
bool isColumnConst() const override { return true; }
bool isNumeric() const override { return data->isNumeric(); }
bool isFixedAndContiguous() const override { return data->isFixedAndContiguous(); }
bool valuesHaveFixedSize() const override { return data->valuesHaveFixedSize(); }
@ -217,4 +216,6 @@ public:
T getValue() const { return getField().safeGet<NearestFieldType<T>>(); }
};
bool isColumnConst(const IColumn & column);
}

View File

@ -27,7 +27,7 @@ ColumnNullable::ColumnNullable(MutableColumnPtr && nested_column_, MutableColumn
if (!getNestedColumn().canBeInsideNullable())
throw Exception{getNestedColumn().getName() + " cannot be inside Nullable column", ErrorCodes::ILLEGAL_COLUMN};
if (null_map->isColumnConst())
if (isColumnConst(*null_map))
throw Exception{"ColumnNullable cannot have constant null map", ErrorCodes::ILLEGAL_COLUMN};
}
@ -457,7 +457,7 @@ ColumnPtr makeNullable(const ColumnPtr & column)
if (checkColumn<ColumnNullable>(*column))
return column;
if (column->isColumnConst())
if (isColumnConst(*column))
return ColumnConst::create(makeNullable(static_cast<const ColumnConst &>(*column).getDataColumnPtr()), column->size());
return ColumnNullable::create(column, ColumnUInt8::create(column->size(), 0));

View File

@ -39,7 +39,7 @@ ColumnTuple::ColumnTuple(MutableColumns && mutable_columns)
columns.reserve(mutable_columns.size());
for (auto & column : mutable_columns)
{
if (column->isColumnConst())
if (isColumnConst(*column))
throw Exception{"ColumnTuple cannot have ColumnConst as its element", ErrorCodes::ILLEGAL_COLUMN};
columns.push_back(std::move(column));
@ -49,7 +49,7 @@ ColumnTuple::ColumnTuple(MutableColumns && mutable_columns)
ColumnTuple::Ptr ColumnTuple::create(const Columns & columns)
{
for (const auto & column : columns)
if (column->isColumnConst())
if (isColumnConst(*column))
throw Exception{"ColumnTuple cannot have ColumnConst as its element", ErrorCodes::ILLEGAL_COLUMN};
auto column_tuple = ColumnTuple::create(MutableColumns());
@ -61,7 +61,7 @@ ColumnTuple::Ptr ColumnTuple::create(const Columns & columns)
ColumnTuple::Ptr ColumnTuple::create(const TupleColumns & columns)
{
for (const auto & column : columns)
if (column->isColumnConst())
if (isColumnConst(*column))
throw Exception{"ColumnTuple cannot have ColumnConst as its element", ErrorCodes::ILLEGAL_COLUMN};
auto column_tuple = ColumnTuple::create(MutableColumns());

View File

@ -23,7 +23,7 @@ ConstantFilterDescription::ConstantFilterDescription(const IColumn & column)
return;
}
if (column.isColumnConst())
if (isColumnConst(column))
{
const ColumnConst & column_const = static_cast<const ColumnConst &>(column);
ColumnPtr column_nested = column_const.getDataColumnPtr()->convertToFullColumnIfLowCardinality();

View File

@ -297,9 +297,6 @@ public:
/// Various properties on behaviour of column type.
/// Column stores a constant value. It's true only for ColumnConst wrapper.
virtual bool isColumnConst() const { return false; }
/// It's a special kind of column, that contain single value, but is not a ColumnConst.
virtual bool isDummy() const { return false; }
@ -432,4 +429,6 @@ bool checkColumn(const IColumn * column)
return checkAndGetColumn<Type>(column);
}
bool isColumnConst(const IColumn & column); /// defined in ColumnConst.cpp
}

View File

@ -31,7 +31,7 @@ ColumnWithTypeAndName getLeastSuperColumn(std::vector<const ColumnWithTypeAndNam
for (size_t i = 0; i < columns.size(); ++i)
{
types[i] = columns[i]->type;
if (columns[i]->column->isColumnConst())
if (isColumnConst(*columns[i]->column))
++num_const;
}

View File

@ -472,7 +472,7 @@ static ReturnType checkBlockStructure(const Block & lhs, const Block & rhs, cons
return on_error("Block structure mismatch in " + context_description + " stream: different columns:\n"
+ lhs.dumpStructure() + "\n" + rhs.dumpStructure(), ErrorCodes::BLOCKS_HAVE_DIFFERENT_STRUCTURE);
if (actual.column->isColumnConst() && expected.column->isColumnConst())
if (isColumnConst(*actual.column) && isColumnConst(*expected.column))
{
Field actual_value = static_cast<const ColumnConst &>(*actual.column).getField();
Field expected_value = static_cast<const ColumnConst &>(*expected.column).getField();

View File

@ -167,8 +167,8 @@ private:
if constexpr (_actual)
{
bool c0_is_const = c0->isColumnConst();
bool c1_is_const = c1->isColumnConst();
bool c0_is_const = isColumnConst(*c0);
bool c1_is_const = isColumnConst(*c1);
if (c0_is_const && c1_is_const)
{

View File

@ -187,7 +187,7 @@ MutableColumnPtr AddingDefaultsBlockInputStream::mixColumns(const ColumnWithType
{
if (defaults_mask[i])
{
if (col_defaults.column->isColumnConst())
if (isColumnConst(*col_defaults.column))
column_mixed->insert((*col_defaults.column)[i]);
else
column_mixed->insertFrom(*col_defaults.column, i);

View File

@ -69,9 +69,9 @@ ConvertingBlockInputStream::ConvertingBlockInputStream(
/// Check constants.
if (res_elem.column->isColumnConst())
if (isColumnConst(*res_elem.column))
{
if (!src_elem.column->isColumnConst())
if (!isColumnConst(*src_elem.column))
throw Exception("Cannot convert column " + backQuoteIfNeed(res_elem.name)
+ " because it is non constant in source stream but must be constant in result",
ErrorCodes::BLOCKS_HAVE_DIFFERENT_STRUCTURE);
@ -103,7 +103,7 @@ Block ConvertingBlockInputStream::readImpl()
ColumnPtr converted = castColumnWithDiagnostic(src_elem, res_elem, context);
if (src_elem.column->isColumnConst() && !res_elem.column->isColumnConst())
if (isColumnConst(*src_elem.column) && !isColumnConst(*res_elem.column))
converted = converted->convertToFullColumnIfConst();
res_elem.column = std::move(converted);

View File

@ -112,7 +112,7 @@ ColumnRawPtrs DistinctBlockInputStream::getKeyColumns(const Block & block) const
: block.getByName(columns_names[i]).column;
/// Ignore all constant columns.
if (!column->isColumnConst())
if (!isColumnConst(*column))
column_ptrs.emplace_back(column.get());
}

View File

@ -131,7 +131,7 @@ ColumnRawPtrs DistinctSortedBlockInputStream::getKeyColumns(const Block & block)
: block.getByName(columns_names[i]).column;
/// Ignore all constant columns.
if (!column->isColumnConst())
if (!isColumnConst(*column))
column_ptrs.emplace_back(column.get());
}

View File

@ -112,7 +112,7 @@ Block FilterBlockInputStream::readImpl()
size_t first_non_constant_column = 0;
for (size_t i = 0; i < columns; ++i)
{
if (!res.safeGetByPosition(i).column->isColumnConst())
if (!isColumnConst(*res.safeGetByPosition(i).column))
{
first_non_constant_column = i;
@ -165,7 +165,7 @@ Block FilterBlockInputStream::readImpl()
if (i == first_non_constant_column)
continue;
if (current_column.column->isColumnConst())
if (isColumnConst(*current_column.column))
current_column.column = current_column.column->cut(0, filtered_rows);
else
current_column.column = current_column.column->filter(*filter_and_holder.data, -1);

View File

@ -144,7 +144,7 @@ void IBlockInputStream::updateExtremes(Block & block)
{
const ColumnPtr & src = block.safeGetByPosition(i).column;
if (src->isColumnConst())
if (isColumnConst(*src))
{
/// Equal min and max.
extremes_columns[i] = src->cloneResized(2);
@ -171,7 +171,7 @@ void IBlockInputStream::updateExtremes(Block & block)
{
ColumnPtr & old_extremes = extremes.safeGetByPosition(i).column;
if (old_extremes->isColumnConst())
if (isColumnConst(*old_extremes))
continue;
Field min_value = (*old_extremes)[0];

View File

@ -71,7 +71,7 @@ ColumnRawPtrs LimitByBlockInputStream::getKeyColumns(Block & block) const
auto & column = block.getByName(name).column;
/// Ignore all constant columns.
if (!column->isColumnConst())
if (!isColumnConst(*column))
column_ptrs.emplace_back(column.get());
}

View File

@ -9,7 +9,7 @@ void removeConstantsFromBlock(Block & block)
size_t i = 0;
while (i < columns)
{
if (block.getByPosition(i).column->isColumnConst())
if (isColumnConst(*block.getByPosition(i).column))
{
block.erase(i);
--columns;
@ -26,9 +26,9 @@ void removeConstantsFromSortDescription(const Block & header, SortDescription &
[&](const SortColumnDescription & elem)
{
if (!elem.column_name.empty())
return header.getByName(elem.column_name).column->isColumnConst();
return isColumnConst(*header.getByName(elem.column_name).column);
else
return header.safeGetByPosition(elem.column_number).column->isColumnConst();
return isColumnConst(*header.safeGetByPosition(elem.column_number).column);
}), description.end());
}
@ -41,7 +41,7 @@ void enrichBlockWithConstants(Block & block, const Block & header)
for (size_t i = 0; i < columns; ++i)
{
const auto & col_type_name = header.getByPosition(i);
if (col_type_name.column->isColumnConst())
if (isColumnConst(*col_type_name.column))
block.insert(i, {col_type_name.column->cloneResized(rows), col_type_name.type, col_type_name.name});
}
}

View File

@ -91,7 +91,7 @@ Block flatten(const Block & block)
const Strings & names = type_tuple->getElementNames();
size_t tuple_size = element_types.size();
bool is_const = elem.column->isColumnConst();
bool is_const = isColumnConst(*elem.column);
const ColumnArray * column_array;
if (is_const)
column_array = typeid_cast<const ColumnArray *>(&static_cast<const ColumnConst &>(*elem.column).getDataColumn());

View File

@ -538,12 +538,12 @@ class FunctionBinaryArithmetic : public IFunction
if (WhichDataType(block.getByPosition(new_arguments[1]).type).isAggregateFunction())
std::swap(new_arguments[0], new_arguments[1]);
if (!block.getByPosition(new_arguments[1]).column->isColumnConst())
if (!isColumnConst(*block.getByPosition(new_arguments[1]).column))
throw Exception{"Illegal column " + block.getByPosition(new_arguments[1]).column->getName()
+ " of argument of aggregation state multiply. Should be integer constant", ErrorCodes::ILLEGAL_COLUMN};
const IColumn & agg_state_column = *block.getByPosition(new_arguments[0]).column;
bool agg_state_is_const = agg_state_column.isColumnConst();
bool agg_state_is_const = isColumnConst(agg_state_column);
const ColumnAggregateFunction & column = typeid_cast<const ColumnAggregateFunction &>(
agg_state_is_const ? static_cast<const ColumnConst &>(agg_state_column).getDataColumn() : agg_state_column);
@ -600,8 +600,8 @@ class FunctionBinaryArithmetic : public IFunction
const IColumn & lhs_column = *block.getByPosition(arguments[0]).column;
const IColumn & rhs_column = *block.getByPosition(arguments[1]).column;
bool lhs_is_const = lhs_column.isColumnConst();
bool rhs_is_const = rhs_column.isColumnConst();
bool lhs_is_const = isColumnConst(lhs_column);
bool rhs_is_const = isColumnConst(rhs_column);
const ColumnAggregateFunction & lhs = typeid_cast<const ColumnAggregateFunction &>(
lhs_is_const ? static_cast<const ColumnConst &>(lhs_column).getDataColumn() : lhs_column);

View File

@ -19,7 +19,7 @@ namespace ErrorCodes
const ColumnConst * checkAndGetColumnConstStringOrFixedString(const IColumn * column)
{
if (!column->isColumnConst())
if (!isColumnConst(*column))
return {};
const ColumnConst * res = static_cast<const ColumnConst *>(column);

View File

@ -25,7 +25,7 @@ const Type * checkAndGetDataType(const IDataType * data_type)
template <typename Type>
const ColumnConst * checkAndGetColumnConst(const IColumn * column)
{
if (!column || !column->isColumnConst())
if (!column || !isColumnConst(*column))
return {};
const ColumnConst * res = static_cast<const ColumnConst *>(column);

View File

@ -56,7 +56,7 @@ namespace ErrorCodes
*
* Two bitmap andnot calculation, return cardinality:
* bitmapAndnotCardinality: bitmap,bitmap -> integer
*
*
* Determine if a bitmap contains the given integer:
* bitmapContains: bitmap,integer -> bool
*
@ -432,28 +432,28 @@ private:
Block & block, const ColumnNumbers & arguments, size_t input_rows_count, typename ColumnVector<UInt8>::Container & vec_to)
{
const IColumn * columns[2];
bool isColumnConst[2];
bool is_column_const[2];
const PaddedPODArray<AggregateDataPtr> * container0;
const PaddedPODArray<UInt32> * container1;
for (size_t i = 0; i < 2; ++i)
{
columns[i] = block.getByPosition(arguments[i]).column.get();
isColumnConst[i] = typeid_cast<const ColumnConst*>(columns[i])!=nullptr;
is_column_const[i] = isColumnConst(*columns[i]);
}
if (isColumnConst[0])
if (is_column_const[0])
container0 = &typeid_cast<const ColumnAggregateFunction*>(typeid_cast<const ColumnConst*>(columns[0])->getDataColumnPtr().get())->getData();
else
container0 = &typeid_cast<const ColumnAggregateFunction*>(columns[0])->getData();
if (isColumnConst[1])
if (is_column_const[1])
container1 = &typeid_cast<const ColumnUInt32*>(typeid_cast<const ColumnConst*>(columns[1])->getDataColumnPtr().get())->getData();
else
container1 = &typeid_cast<const ColumnUInt32*>(columns[1])->getData();
for (size_t i = 0; i < input_rows_count; ++i)
{
const AggregateDataPtr dataPtr0 = isColumnConst[0] ? (*container0)[0] : (*container0)[i];
const UInt32 data1 = isColumnConst[1] ? (*container1)[0] : (*container1)[i];
const AggregateDataPtr dataPtr0 = is_column_const[0] ? (*container0)[0] : (*container0)[i];
const UInt32 data1 = is_column_const[1] ? (*container1)[0] : (*container1)[i];
const AggregateFunctionGroupBitmapData<T>& bd0
= *reinterpret_cast<const AggregateFunctionGroupBitmapData<T>*>(dataPtr0);
vec_to[i] = bd0.rbs.rb_contains(data1);
@ -529,18 +529,18 @@ private:
Block & block, const ColumnNumbers & arguments, size_t input_rows_count, typename ColumnVector<ToType>::Container & vec_to)
{
const ColumnAggregateFunction * columns[2];
bool isColumnConst[2];
bool is_column_const[2];
for (size_t i = 0; i < 2; ++i)
{
if (auto argument_column_const = typeid_cast<const ColumnConst*>(block.getByPosition(arguments[i]).column.get()))
if (auto argument_column_const = checkAndGetColumn<ColumnConst>(block.getByPosition(arguments[i]).column.get()))
{
columns[i] = typeid_cast<const ColumnAggregateFunction*>(argument_column_const->getDataColumnPtr().get());
isColumnConst[i] = true;
is_column_const[i] = true;
}
else
{
columns[i] = typeid_cast<const ColumnAggregateFunction*>(block.getByPosition(arguments[i]).column.get());
isColumnConst[i] = false;
is_column_const[i] = false;
}
}
@ -549,8 +549,8 @@ private:
for (size_t i = 0; i < input_rows_count; ++i)
{
const AggregateDataPtr dataPtr0 = isColumnConst[0] ? container0[0] : container0[i];
const AggregateDataPtr dataPtr1 = isColumnConst[1] ? container1[0] : container1[i];
const AggregateDataPtr dataPtr0 = is_column_const[0] ? container0[0] : container0[i];
const AggregateDataPtr dataPtr1 = is_column_const[1] ? container1[0] : container1[i];
const AggregateFunctionGroupBitmapData<T> & bd1
= *reinterpret_cast<const AggregateFunctionGroupBitmapData<T>*>(dataPtr0);
const AggregateFunctionGroupBitmapData<T> & bd2

View File

@ -1032,8 +1032,8 @@ private:
void executeGenericIdenticalTypes(Block & block, size_t result, const IColumn * c0, const IColumn * c1)
{
bool c0_const = c0->isColumnConst();
bool c1_const = c1->isColumnConst();
bool c0_const = isColumnConst(*c0);
bool c1_const = isColumnConst(*c1);
if (c0_const && c1_const)
{

View File

@ -133,7 +133,7 @@ public:
void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result, size_t /*input_rows_count*/) override
{
if (block.getByPosition(arguments[1]).column->isColumnConst())
if (isColumnConst(*block.getByPosition(arguments[1]).column))
executeConstBuckets(block, arguments, result);
else
throw Exception(

View File

@ -1894,7 +1894,7 @@ private:
template <typename T>
static const PaddedPODArray<T> & getColumnDataAsPaddedPODArray(const IColumn & column, PaddedPODArray<T> & backup_storage)
{
if (!column.isColumnConst())
if (!isColumnConst(column))
{
if (const auto vector_col = checkAndGetColumn<ColumnVector<T>>(&column))
{

View File

@ -130,7 +130,7 @@ public:
auto column_result = block.getByPosition(result).type->createColumn();
auto out_untyped = column_result.get();
if (!centroids_array_untyped->isColumnConst())
if (!isColumnConst(*centroids_array_untyped))
throw Exception{"Second argument of function " + getName() + " must be literal array", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
executeImplTyped(in_untyped, out_untyped, centroids_array_untyped);

View File

@ -1041,7 +1041,7 @@ private:
void executeTwoArgs(Block & block, const ColumnNumbers & arguments, const size_t result) const
{
const auto level_col = block.getByPosition(arguments.back()).column.get();
if (!level_col->isColumnConst())
if (!isColumnConst(*level_col))
throw Exception{"Second argument of function " + getName() + " must be an integral constant", ErrorCodes::ILLEGAL_COLUMN};
const auto level = level_col->get64(0);

View File

@ -213,7 +213,7 @@ private:
+ " should be a string specifying key or an integer specifying index, illegal type: " + column.type->getName(),
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
if (column.column->isColumnConst())
if (isColumnConst(*column.column))
{
const auto & column_const = static_cast<const ColumnConst &>(*column.column);
if (isString(column.type))

View File

@ -211,7 +211,7 @@ private:
bool has_res = false;
for (int i = static_cast<int>(in.size()) - 1; i >= 0; --i)
{
if (!in[i]->isColumnConst())
if (!isColumnConst(*in[i]))
continue;
Field value = (*in[i])[0];

View File

@ -512,7 +512,7 @@ public:
if (arguments.size() == 2)
{
const IColumn & scale_column = *block.getByPosition(arguments[1]).column;
if (!scale_column.isColumnConst())
if (!isColumnConst(scale_column))
throw Exception("Scale argument for rounding functions must be constant.", ErrorCodes::ILLEGAL_COLUMN);
Field scale_field = static_cast<const ColumnConst &>(scale_column).getField();

View File

@ -814,7 +814,7 @@ public:
const ColumnPtr column_needle = block.getByPosition(arguments[1]).column;
const ColumnPtr column_replacement = block.getByPosition(arguments[2]).column;
if (!column_needle->isColumnConst() || !column_replacement->isColumnConst())
if (!isColumnConst(*column_needle) || !isColumnConst(*column_replacement))
throw Exception("2nd and 3rd arguments of function " + getName() + " must be constants.", ErrorCodes::ILLEGAL_COLUMN);
const IColumn * c1 = block.getByPosition(arguments[1]).column.get();

View File

@ -127,7 +127,7 @@ ColumnPtr wrapInNullable(const ColumnPtr & src, const Block & block, const Colum
if (elem.column->onlyNull())
return block.getByPosition(result).type->createColumnConst(input_rows_count, Null());
if (elem.column->isColumnConst())
if (isColumnConst(*elem.column))
continue;
if (auto * nullable = checkAndGetColumn<ColumnNullable>(*elem.column))
@ -204,7 +204,7 @@ NullPresence getNullPresense(const ColumnsWithTypeAndName & args)
bool allArgumentsAreConstants(const Block & block, const ColumnNumbers & args)
{
for (auto arg : args)
if (!block.getByPosition(arg).column->isColumnConst())
if (!isColumnConst(*block.getByPosition(arg).column))
return false;
return true;
}
@ -217,7 +217,7 @@ bool PreparedFunctionImpl::defaultImplementationForConstantArguments(Block & blo
/// Check that these arguments are really constant.
for (auto arg_num : arguments_to_remain_constants)
if (arg_num < args.size() && !block.getByPosition(args[arg_num]).column->isColumnConst())
if (arg_num < args.size() && !isColumnConst(*block.getByPosition(args[arg_num]).column))
throw Exception("Argument at index " + toString(arg_num) + " for function " + getName() + " must be constant", ErrorCodes::ILLEGAL_COLUMN);
if (args.empty() || !useDefaultImplementationForConstants() || !allArgumentsAreConstants(block, args))
@ -583,7 +583,7 @@ DataTypePtr FunctionBuilderImpl::getReturnType(const ColumnsWithTypeAndName & ar
for (ColumnWithTypeAndName & arg : args_without_low_cardinality)
{
bool is_const = arg.column && arg.column->isColumnConst();
bool is_const = arg.column && isColumnConst(*arg.column);
if (is_const)
arg.column = static_cast<const ColumnConst &>(*arg.column).removeLowCardinality();

View File

@ -836,7 +836,7 @@ void FunctionArrayElement::perform(Block & block, const ColumnNumbers & argument
if (executeTuple(block, arguments, result, input_rows_count))
{
}
else if (!block.getByPosition(arguments[1]).column->isColumnConst())
else if (!isColumnConst(*block.getByPosition(arguments[1]).column))
{
if (!(executeArgument<UInt8>(block, arguments, result, builder, input_rows_count)
|| executeArgument<UInt16>(block, arguments, result, builder, input_rows_count)

View File

@ -47,7 +47,7 @@ ArraysDepths getArraysDepths(const ColumnsWithTypeAndName & arguments)
{
const auto & depth_column = arguments[i].column;
if (depth_column && depth_column->isColumnConst())
if (depth_column && isColumnConst(*depth_column))
{
UInt64 value = static_cast<const ColumnConst &>(*depth_column).getValue<UInt64>();
if (!value)

View File

@ -751,7 +751,7 @@ private:
Array arr = col_array->getValue<Array>();
const auto item_arg = block.getByPosition(arguments[1]).column.get();
if (item_arg->isColumnConst())
if (isColumnConst(*item_arg))
{
typename IndexConv::ResultType current = 0;
const auto & value = (*item_arg)[0];
@ -848,7 +848,7 @@ private:
if (item_arg.onlyNull())
ArrayIndexGenericNullImpl<IndexConv>::vector(col_nested, col_array->getOffsets(),
col_res->getData(), null_map_data);
else if (item_arg.isColumnConst())
else if (isColumnConst(item_arg))
ArrayIndexGenericImpl<IndexConv, true>::vector(col_nested, col_array->getOffsets(),
static_cast<const ColumnConst &>(item_arg).getDataColumn(), col_res->getData(), /// TODO This is wrong.
null_map_data, nullptr);

View File

@ -124,7 +124,7 @@ public:
auto sink = GatherUtils::createArraySink(typeid_cast<ColumnArray &>(*result_column), size);
if (size_column->isColumnConst())
if (isColumnConst(*size_column))
GatherUtils::resizeConstantSize(*array_source, *value_source, *sink, size_column->getInt(0));
else
GatherUtils::resizeDynamicSize(*array_source, *value_source, *sink, *size_column);

View File

@ -110,7 +110,7 @@ public:
block.getByPosition(result).column = array_column;
return;
}
else if (length_column->isColumnConst())
else if (isColumnConst(*length_column))
GatherUtils::sliceFromLeftConstantOffsetBounded(*source, *sink, 0, length_column->getInt(0));
else
{
@ -118,7 +118,7 @@ public:
GatherUtils::sliceDynamicOffsetBounded(*source, *sink, *const_offset_column, *length_column);
}
}
else if (offset_column->isColumnConst())
else if (isColumnConst(*offset_column))
{
ssize_t offset = offset_column->getUInt(0);
@ -129,7 +129,7 @@ public:
else
GatherUtils::sliceFromRightConstantOffsetUnbounded(*source, *sink, static_cast<size_t>(-offset));
}
else if (length_column->isColumnConst())
else if (isColumnConst(*length_column))
{
ssize_t length = length_column->getInt(0);
if (offset > 0)

View File

@ -108,7 +108,7 @@ private:
{
const auto & column = *block.getByPosition(arguments[argument_pos]).column;
if (!column.isColumnConst())
if (!isColumnConst(column))
throw Exception(
which_argument + String(" argument for function ") + getName() + " must be constant.", ErrorCodes::ILLEGAL_COLUMN);

View File

@ -605,8 +605,8 @@ private:
MutableColumnPtr result_column = common_type->createColumn();
result_column->reserve(input_rows_count);
bool then_is_const = col_then->isColumnConst();
bool else_is_const = col_else->isColumnConst();
bool then_is_const = isColumnConst(*col_then);
bool else_is_const = isColumnConst(*col_else);
const auto & cond_array = cond_col->getData();

View File

@ -141,7 +141,7 @@ public:
if (cond_col.column->onlyNull())
continue;
if (cond_col.column->isColumnConst())
if (isColumnConst(*cond_col.column))
{
Field value = typeid_cast<const ColumnConst &>(*cond_col.column).getField();
if (value.isNull())
@ -171,7 +171,7 @@ public:
instruction.source = converted_columns_holder.back().get();
}
if (instruction.source && instruction.source->isColumnConst())
if (instruction.source && isColumnConst(*instruction.source))
instruction.source_is_constant = true;
instructions.emplace_back(std::move(instruction));

View File

@ -167,7 +167,7 @@ public:
const auto & res_type = block.getByPosition(result).type;
/// When column is constant, its difference is zero.
if (src.column->isColumnConst())
if (isColumnConst(*src.column))
{
block.getByPosition(result).column = res_type->createColumnConstWithDefaultValue(input_rows_count);
return;

View File

@ -69,7 +69,7 @@ public:
{
const IColumn * col = block.getByPosition(arguments[0]).column.get();
if (!col->isColumnConst())
if (!isColumnConst(*col))
throw Exception("The argument of function " + getName() + " must be constant.", ErrorCodes::ILLEGAL_COLUMN);
Float64 seconds = applyVisitor(FieldVisitorConvertToNumber<Float64>(), static_cast<const ColumnConst &>(*col).getField());

View File

@ -155,7 +155,7 @@ public:
const auto in = block.getByPosition(arguments.front()).column.get();
if (in->isColumnConst())
if (isColumnConst(*in))
{
executeConst(block, arguments, result, input_rows_count);
return;
@ -228,7 +228,7 @@ private:
executeImplNumToNum<T>(in->getData(), out->getData());
}
else if (default_untyped->isColumnConst())
else if (isColumnConst(*default_untyped))
{
if (!executeNumToNumWithConstDefault<T, UInt8>(in, out_untyped)
&& !executeNumToNumWithConstDefault<T, UInt16>(in, out_untyped)
@ -281,7 +281,7 @@ private:
throw Exception{"Illegal column " + in->getName() + " of elements of array of second argument of function " + getName(),
ErrorCodes::ILLEGAL_COLUMN};
}
else if (default_untyped->isColumnConst())
else if (isColumnConst(*default_untyped))
{
if (!executeStringToNumWithConstDefault<UInt8>(in, out_untyped)
&& !executeStringToNumWithConstDefault<UInt16>(in, out_untyped)

View File

@ -1233,7 +1233,7 @@ Block Aggregator::prepareBlockAndFill(
/// Change the size of the columns-constants in the block.
size_t columns = header.columns();
for (size_t i = 0; i < columns; ++i)
if (res.getByPosition(i).column->isColumnConst())
if (isColumnConst(*res.getByPosition(i).column))
res.getByPosition(i).column = res.getByPosition(i).column->cut(0, rows);
return res;

View File

@ -191,7 +191,7 @@ void ExpressionAction::prepare(Block & sample_block, const Settings & settings)
{
arguments[i] = sample_block.getPositionByName(argument_names[i]);
ColumnPtr col = sample_block.safeGetByPosition(arguments[i]).column;
if (!col || !col->isColumnConst())
if (!col || !isColumnConst(*col))
all_const = false;
}
@ -215,7 +215,7 @@ void ExpressionAction::prepare(Block & sample_block, const Settings & settings)
/// If the result is not a constant, just in case, we will consider the result as unknown.
ColumnWithTypeAndName & col = sample_block.safeGetByPosition(result_position);
if (!col.column->isColumnConst())
if (!isColumnConst(*col.column))
{
col.column = nullptr;
}
@ -610,14 +610,14 @@ void ExpressionActions::checkLimits(Block & block) const
{
size_t non_const_columns = 0;
for (size_t i = 0, size = block.columns(); i < size; ++i)
if (block.safeGetByPosition(i).column && !block.safeGetByPosition(i).column->isColumnConst())
if (block.safeGetByPosition(i).column && !isColumnConst(*block.safeGetByPosition(i).column))
++non_const_columns;
if (non_const_columns > settings.max_temporary_non_const_columns)
{
std::stringstream list_of_non_const_columns;
for (size_t i = 0, size = block.columns(); i < size; ++i)
if (block.safeGetByPosition(i).column && !block.safeGetByPosition(i).column->isColumnConst())
if (block.safeGetByPosition(i).column && !isColumnConst(*block.safeGetByPosition(i).column))
list_of_non_const_columns << "\n" << block.safeGetByPosition(i).name;
throw Exception("Too many temporary non-const columns:" + list_of_non_const_columns.str()

View File

@ -186,7 +186,7 @@ void ExpressionAnalyzer::analyzeAggregation()
const auto & col = block.getByName(column_name);
/// Constant expressions have non-null column pointer at this stage.
if (col.column && col.column->isColumnConst())
if (col.column && isColumnConst(*col.column))
{
/// But don't remove last key column if no aggregate functions, otherwise aggregation will not work.
if (!aggregate_descriptions.empty() || size > 1)

View File

@ -85,7 +85,7 @@ namespace
static ColumnData getColumnData(const IColumn * column)
{
ColumnData result;
const bool is_const = column->isColumnConst();
const bool is_const = isColumnConst(*column);
if (is_const)
column = &reinterpret_cast<const ColumnConst *>(column)->getDataColumn();
if (auto * nullable = typeid_cast<const ColumnNullable *>(column))

View File

@ -140,7 +140,7 @@ Join::Type Join::chooseMethod(const ColumnRawPtrs & key_columns, Sizes & key_siz
/// If there is single string key, use hash table of it's values.
if (keys_size == 1
&& (typeid_cast<const ColumnString *>(key_columns[0])
|| (key_columns[0]->isColumnConst() && typeid_cast<const ColumnString *>(&static_cast<const ColumnConst *>(key_columns[0])->getDataColumn()))))
|| (isColumnConst(*key_columns[0]) && typeid_cast<const ColumnString *>(&static_cast<const ColumnConst *>(key_columns[0])->getDataColumn()))))
return Type::key_string;
if (keys_size == 1 && typeid_cast<const ColumnFixedString *>(key_columns[0]))

View File

@ -156,7 +156,7 @@ typename SetVariantsTemplate<Variant>::Type SetVariantsTemplate<Variant>::choose
/// If there is single string key, use hash table of it's values.
if (keys_size == 1
&& (typeid_cast<const ColumnString *>(nested_key_columns[0])
|| (nested_key_columns[0]->isColumnConst() && typeid_cast<const ColumnString *>(&static_cast<const ColumnConst *>(nested_key_columns[0])->getDataColumn()))))
|| (isColumnConst(*nested_key_columns[0]) && typeid_cast<const ColumnString *>(&static_cast<const ColumnConst *>(nested_key_columns[0])->getDataColumn()))))
return Type::key_string;
if (keys_size == 1 && typeid_cast<const ColumnFixedString *>(nested_key_columns[0]))

View File

@ -30,7 +30,7 @@ IColumn::Selector createBlockSelector(
using UnsignedT = std::make_unsigned_t<T>;
/// const columns contain only one value, therefore we do not need to read it at every iteration
if (column.isColumnConst())
if (isColumnConst(column))
{
const auto data = static_cast<const ColumnConst &>(column).getValue<T>();
const auto shard_num = slots[static_cast<UnsignedT>(data) % total_weight];

View File

@ -50,7 +50,7 @@ std::pair<Field, std::shared_ptr<const IDataType>> evaluateConstantExpression(co
const ColumnWithTypeAndName & result = block_with_constants.getByName(name);
const IColumn & result_column = *result.column;
if (!result_column.isColumnConst())
if (!isColumnConst(result_column))
throw Exception("Element of set in IN, VALUES or LIMIT is not a constant expression: " + name, ErrorCodes::BAD_ARGUMENTS);
return std::make_pair(result_column[0], result.type);

View File

@ -334,7 +334,7 @@ bool KeyCondition::getConstant(const ASTPtr & expr, Block & block_with_constants
out_type = block_with_constants.getByName(column_name).type;
return true;
}
else if (block_with_constants.has(column_name) && block_with_constants.getByName(column_name).column->isColumnConst())
else if (block_with_constants.has(column_name) && isColumnConst(*block_with_constants.getByName(column_name).column))
{
/// An expression which is dependent on constants only
const auto & expr_info = block_with_constants.getByName(column_name);

View File

@ -243,7 +243,7 @@ static void checkKeyExpression(const ExpressionActions & expr, const Block & sam
for (const ColumnWithTypeAndName & element : sample_block)
{
const ColumnPtr & column = element.column;
if (column && (column->isColumnConst() || column->isDummy()))
if (column && (isColumnConst(*column) || column->isDummy()))
throw Exception{key_name + " key cannot contain constants", ErrorCodes::ILLEGAL_COLUMN};
if (element.type->isNullable())

View File

@ -303,7 +303,7 @@ bool MergeTreeWhereOptimizer::isConstant(const ASTPtr & expr) const
const auto column_name = expr->getColumnName();
if (expr->as<ASTLiteral>()
|| (block_with_constants.has(column_name) && block_with_constants.getByName(column_name).column->isColumnConst()))
|| (block_with_constants.has(column_name) && isColumnConst(*block_with_constants.getByName(column_name).column)))
return true;
return false;