Implement AggregateFunctionCountNotNullUnary::addBatchSinglePlace

This commit is contained in:
Raúl Marín 2021-11-25 16:41:48 +01:00
parent b39c19399f
commit a22f7c159e
3 changed files with 35 additions and 0 deletions

View File

@ -203,6 +203,21 @@ public:
data(place).count += !assert_cast<const ColumnNullable &>(*columns[0]).isNullAt(row_num);
}
void addBatchSinglePlace(
size_t batch_size, AggregateDataPtr place, const IColumn ** columns, Arena *, ssize_t if_argument_pos) const override
{
auto & nc = assert_cast<const ColumnNullable &>(*columns[0]);
if (if_argument_pos >= 0)
{
const auto & flags = assert_cast<const ColumnUInt8 &>(*columns[if_argument_pos]).getData();
data(place).count += countBytesInFilterWithNull(flags, nc.getNullMapData().data());
}
else
{
data(place).count += batch_size - countBytesInFilter(nc.getNullMapData().data(), batch_size);
}
}
void merge(AggregateDataPtr __restrict place, ConstAggregateDataPtr rhs, Arena *) const override
{
data(place).count += data(rhs).count;

View File

@ -4,6 +4,8 @@
<fill_query>INSERT INTO data SELECT number, 1 from numbers(10000000)</fill_query>
<query tag='count_10M' short='1'>SELECT count() FROM data</query>
<query>SELECT count(k) FROM data</query>
<query>SELECT count(toNullable(k)) FROM data</query>
<drop_query>DROP TABLE IF EXISTS data</drop_query>
</test>

View File

@ -1,3 +1,21 @@
<test>
<query>SELECT countIf(number % 2) FROM numbers(100000000)</query>
<query>
SELECT countIf(key IS NOT NULL)
FROM
(
SELECT materialize(toNullable(1)) AS key
FROM numbers(100000000)
)
</query>
<query>
SELECT countIf(key IS NOT NULL)
FROM
(
SELECT materialize(CAST(NULL, 'Nullable(Int8)')) AS key
FROM numbers(100000000)
)
</query>
</test>