mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 19:12:03 +00:00
Add a bunch of important asserts
This commit is contained in:
parent
8051e1eca3
commit
a4f90d54f8
@ -111,6 +111,33 @@ void convertLowCardinalityColumnsToFull(ColumnsWithTypeAndName & args)
|
||||
}
|
||||
}
|
||||
|
||||
void checkColumnSizes(const ColumnsWithTypeAndName & arguments [[maybe_unused]], size_t input_rows_count [[maybe_unused]])
|
||||
{
|
||||
if (!arguments.empty())
|
||||
{
|
||||
/// Note that ideally this check should be simpler and we should check that all columns should either be const
|
||||
/// or have exactly size input_rows_count
|
||||
/// For historical reasons this is not the case, and many functions rely on the size of the first column
|
||||
/// to decide which is the size of all the inputs
|
||||
/// Hopefully this will be slowly improved in the future
|
||||
|
||||
if (!isColumnConst(*arguments[0].column))
|
||||
{
|
||||
size_t expected_size = arguments[0].column->size();
|
||||
|
||||
for (size_t i = 1; i < arguments.size(); i++)
|
||||
if (!isColumnConst(*arguments[i].column) && arguments[i].column->size() != expected_size)
|
||||
throw Exception(
|
||||
ErrorCodes::LOGICAL_ERROR,
|
||||
"Expected the #{} column ({} of type {}) to have {} rows, but it has {}",
|
||||
i + 1,
|
||||
arguments[i].name,
|
||||
arguments[i].type->getName(),
|
||||
expected_size,
|
||||
arguments[i].column->size());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ColumnPtr IExecutableFunction::defaultImplementationForConstantArguments(
|
||||
@ -277,6 +304,7 @@ ColumnPtr IExecutableFunction::executeWithoutSparseColumns(const ColumnsWithType
|
||||
size_t new_input_rows_count = columns_without_low_cardinality.empty()
|
||||
? input_rows_count
|
||||
: columns_without_low_cardinality.front().column->size();
|
||||
checkColumnSizes(columns_without_low_cardinality, new_input_rows_count);
|
||||
|
||||
auto res = executeWithoutLowCardinalityColumns(columns_without_low_cardinality, dictionary_type, new_input_rows_count, dry_run);
|
||||
bool res_is_constant = isColumnConst(*res);
|
||||
@ -311,6 +339,8 @@ ColumnPtr IExecutableFunction::executeWithoutSparseColumns(const ColumnsWithType
|
||||
|
||||
ColumnPtr IExecutableFunction::execute(const ColumnsWithTypeAndName & arguments, const DataTypePtr & result_type, size_t input_rows_count, bool dry_run) const
|
||||
{
|
||||
checkColumnSizes(arguments, input_rows_count);
|
||||
|
||||
bool use_default_implementation_for_sparse_columns = useDefaultImplementationForSparseColumns();
|
||||
/// DataTypeFunction does not support obtaining default (isDefaultAt())
|
||||
/// ColumnFunction does not support getting specific values.
|
||||
@ -576,6 +606,13 @@ llvm::Value * IFunction::compile(llvm::IRBuilderBase & builder, const ValuesWith
|
||||
return compileImpl(builder, arguments, result_type);
|
||||
}
|
||||
|
||||
ColumnPtr IFunctionBase::execute(
|
||||
const DB::ColumnsWithTypeAndName & arguments, const DB::DataTypePtr & result_type, size_t input_rows_count, bool dry_run) const
|
||||
{
|
||||
checkColumnSizes(arguments, input_rows_count);
|
||||
return prepare(arguments)->execute(arguments, result_type, input_rows_count, dry_run);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -133,10 +133,10 @@ public:
|
||||
~IFunctionBase() override = default;
|
||||
|
||||
virtual ColumnPtr execute( /// NOLINT
|
||||
const ColumnsWithTypeAndName & arguments, const DataTypePtr & result_type, size_t input_rows_count, bool dry_run = false) const
|
||||
{
|
||||
return prepare(arguments)->execute(arguments, result_type, input_rows_count, dry_run);
|
||||
}
|
||||
const ColumnsWithTypeAndName & arguments,
|
||||
const DataTypePtr & result_type,
|
||||
size_t input_rows_count,
|
||||
bool dry_run = false) const;
|
||||
|
||||
/// Get the main function name.
|
||||
virtual String getName() const = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user