mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Fix tests, add comments
This commit is contained in:
parent
2c4453f425
commit
ae2754ee56
@ -1106,6 +1106,9 @@ public:
|
||||
|
||||
bool useDefaultImplementationForNulls() const override
|
||||
{
|
||||
/// We shouldn't use default implementation for nulls for the case when operation is divide,
|
||||
/// intDiv or modulo and denominator is Nullable(Something), because it may cause division
|
||||
/// by zero error (when value is Null we store default value 0 in nested column).
|
||||
return !division_by_nullable;
|
||||
}
|
||||
|
||||
@ -1593,6 +1596,8 @@ public:
|
||||
const auto & left_argument = arguments[0];
|
||||
const auto & right_argument = arguments[1];
|
||||
|
||||
/// Process special case when operation is divide, intDiv or modulo and denominator
|
||||
/// is Nullable(Something) to prevent division by zero error.
|
||||
if (division_by_nullable && !right_nullmap)
|
||||
{
|
||||
assert(right_argument.type->isNullable());
|
||||
@ -1601,8 +1606,6 @@ public:
|
||||
const ColumnNullable * nullable_column = is_const ? checkAndGetColumnConstData<ColumnNullable>(right_argument.column.get())
|
||||
: checkAndGetColumn<ColumnNullable>(*right_argument.column);
|
||||
|
||||
assert(nullable_column);
|
||||
|
||||
const auto & null_bytemap = nullable_column->getNullMapData();
|
||||
auto res = executeImpl2(createBlockWithNestedColumns(arguments), removeNullable(result_type), input_rows_count, &null_bytemap);
|
||||
return wrapInNullable(res, arguments, result_type, input_rows_count);
|
||||
@ -1915,7 +1918,9 @@ public:
|
||||
|
||||
FunctionBasePtr buildImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr & return_type) const override
|
||||
{
|
||||
bool division_by_nullable = arguments[1].type->isNullable()
|
||||
/// Check the case when operation is divide, intDiv or modulo and denominator is Nullable(Something).
|
||||
/// For divide operation we should check only Nullable(Decimal), because only this case can throw division by zero error.
|
||||
bool division_by_nullable = !arguments[0].type->onlyNull() && !arguments[1].type->onlyNull() && arguments[1].type->isNullable()
|
||||
&& (IsOperation<Op>::div_int || IsOperation<Op>::modulo
|
||||
|| (IsOperation<Op>::div_floating
|
||||
&& (isDecimalOrNullableDecimal(arguments[0].type) || isDecimalOrNullableDecimal(arguments[1].type))));
|
||||
|
Loading…
Reference in New Issue
Block a user