Skip to content

Commit

Permalink
Make bitwise aggregation functions' results always not-null.
Browse files Browse the repository at this point in the history
Signed-off-by: hezheyu <rinchannow@bupt.edu.cn>
  • Loading branch information
RinChanNOWWW committed Jul 6, 2022
1 parent 44fa596 commit 3788123
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions dbms/src/AggregateFunctions/AggregateFunctionNull.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,19 @@ class AggregateFunctionNullUnary final : public AggregateFunctionNullBase<result
if constexpr (input_is_nullable)
{
const ColumnNullable * column = static_cast<const ColumnNullable *>(columns[0]);
const String & nexted_func_name = this->nested_function->getName();
if (!column->isNullAt(row_num))
{
this->setFlag(place);
const IColumn * nested_column = &column->getNestedColumn();
this->nested_function->add(this->nestedPlace(place), &nested_column, row_num, arena);
}
else if (nexted_func_name == "groupBitOr" || nexted_func_name == "groupBitAnd" || nexted_func_name == "groupBitXor")
{
// If nested_function is bitwise aggregation function,
// the result is always not null.
this->setFlag(place);
}
}
else
{
Expand All @@ -458,6 +465,7 @@ class AggregateFunctionNullUnary final : public AggregateFunctionNullBase<result
const ColumnNullable * column = assert_cast<const ColumnNullable *>(columns[0]);
const IColumn * nested_column = &column->getNestedColumn();
const UInt8 * null_map = column->getNullMapData().data();
const String & nexted_func_name = this->nested_function->getName();

this->nested_function->addBatchSinglePlaceNotNull(
batch_size,
Expand All @@ -467,6 +475,13 @@ class AggregateFunctionNullUnary final : public AggregateFunctionNullBase<result
arena,
if_argument_pos);

if (nexted_func_name == "groupBitOr" || nexted_func_name == "groupBitAnd" || nexted_func_name == "groupBitXor")
{
// If nested_function is bitwise aggregation function,
// the result is always not null.
this->setFlag(place);
}

if constexpr (result_is_nullable)
if (!mem_utils::memoryIsByte(null_map, batch_size, std::byte{1}))
this->setFlag(place);
Expand Down

0 comments on commit 3788123

Please sign in to comment.