mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 18:12:02 +00:00
Fix all key value is null and group use rollup return wrong answer
This commit is contained in:
parent
9a67616791
commit
279970337a
@ -2102,6 +2102,7 @@ Aggregator::convertToBlockImplNotFinal(Method & method, Table & data, Arenas & a
|
||||
|
||||
std::optional<OutputBlockColumns> out_cols;
|
||||
std::optional<Sizes> shuffled_key_sizes;
|
||||
size_t rows_in_current_block = 0;
|
||||
|
||||
auto init_out_cols = [&]()
|
||||
{
|
||||
@ -2116,6 +2117,7 @@ Aggregator::convertToBlockImplNotFinal(Method & method, Table & data, Arenas & a
|
||||
for (size_t i = 0; i < params.aggregates_size; ++i)
|
||||
out_cols->aggregate_columns_data[i]->push_back(data.getNullKeyData() + offsets_of_aggregate_states[i]);
|
||||
|
||||
++rows_in_current_block;
|
||||
data.getNullKeyData() = nullptr;
|
||||
data.hasNullKeyData() = false;
|
||||
}
|
||||
@ -2127,8 +2129,6 @@ Aggregator::convertToBlockImplNotFinal(Method & method, Table & data, Arenas & a
|
||||
// should be invoked at least once, because null data might be the only content of the `data`
|
||||
init_out_cols();
|
||||
|
||||
size_t rows_in_current_block = 0;
|
||||
|
||||
data.forEachValue(
|
||||
[&](const auto & key, auto & mapped)
|
||||
{
|
||||
|
@ -0,0 +1,10 @@
|
||||
\N 2
|
||||
|
||||
\N 2
|
||||
\N 2
|
||||
|
||||
\N 2
|
||||
\N 2
|
||||
\N 2
|
||||
\N 2
|
||||
\N 2
|
@ -0,0 +1,13 @@
|
||||
set allow_suspicious_low_cardinality_types=1;
|
||||
DROP TABLE IF EXISTS group_by_null_key;
|
||||
CREATE TABLE group_by_null_key (c1 Nullable(Int32), c2 LowCardinality(Nullable(Int32))) ENGINE = Memory();
|
||||
INSERT INTO group_by_null_key VALUES (null, null), (null, null);
|
||||
|
||||
select c1, count(*) from group_by_null_key group by c1 WITH TOTALS;
|
||||
select c2, count(*) from group_by_null_key group by c2 WITH TOTALS;
|
||||
|
||||
select c1, count(*) from group_by_null_key group by ROLLUP(c1);
|
||||
select c2, count(*) from group_by_null_key group by ROLLUP(c2);
|
||||
|
||||
|
||||
DROP TABLE group_by_null_key;
|
Loading…
Reference in New Issue
Block a user