Fix SummingMergeTree aggregation for Nested LowCardinality columns#90927
Conversation
With `String` we see the expected behavior of the `Nested` column:
```
:) create table sums (key LowCardinality(String), sumOfSums UInt64, sumsMap Nested (key String, sum UInt64)) ENGINE = SummingMergeTree primary key (key)
:) insert into sums (key, sumOfSums, sumsMap.key, sumsMap.sum) values ('lol', 3, ['a', 'b'], [1, 2])
:) insert into sums (key, sumOfSums, sumsMap.key, sumsMap.sum) values ('lol', 7, ['a', 'b'], [3, 4])
:) select * from sums
┌─key─┬─sumOfSums─┬─sumsMap.key─┬─sumsMap.sum─┐
1. │ lol │ 7 │ ['a','b'] │ [3,4] │
2. │ lol │ 3 │ ['a','b'] │ [1,2] │
└─────┴───────────┴─────────────┴─────────────┘
:) optimize table sums
:) select * from sums
┌─key─┬─sumOfSums─┬─sumsMap.key─┬─sumsMap.sum─┐
1. │ lol │ 10 │ ['a','b'] │ [4,6] │
└─────┴───────────┴─────────────┴─────────────┘
```
With `LowCardinality(String)` before we see incorrect summing of the `Nested` column:
```
:) create table sums (key LowCardinality(String), sumOfSums UInt64, sumsMap Nested (key LowCardinality(String), sum UInt64)) ENGINE = SummingMergeTree primary key (key)
:) insert into sums (key, sumOfSums, sumsMap.key, sumsMap.sum) values ('lol', 3, ['a', 'b'], [1, 2])
:) insert into sums (key, sumOfSums, sumsMap.key, sumsMap.sum) values ('lol', 7, ['a', 'b'], [3, 4])
:) select * from sums
┌─key─┬─sumOfSums─┬─sumsMap.key─┬─sumsMap.sum─┐
1. │ lol │ 7 │ ['a','b'] │ [3,4] │
2. │ lol │ 3 │ ['a','b'] │ [1,2] │
└─────┴───────────┴─────────────┴─────────────┘
:) optimize table sums
:) select * from sums
┌─key─┬─sumOfSums─┬─sumsMap.key─┬─sumsMap.sum─┐
1. │ lol │ 10 │ ['a','b'] │ [1,2] │
└─────┴───────────┴─────────────┴─────────────┘
```
With this patch applied `LowCardinality(String)` behaves exactly like `String`, as it should:
```
:) create table sums (key LowCardinality(String), sumOfSums UInt64, sumsMap Nested (key LowCardinality(String), sum UInt64)) ENGINE = SummingMergeTree primary key (key)
:) insert into sums (key, sumOfSums, sumsMap.key, sumsMap.sum) values ('lol', 3, ['a', 'b'], [1, 2])
:) insert into sums (key, sumOfSums, sumsMap.key, sumsMap.sum) values ('lol', 7, ['a', 'b'], [3, 4])
:) select * from sums
┌─key─┬─sumOfSums─┬─sumsMap.key─┬─sumsMap.sum─┐
1. │ lol │ 3 │ ['a','b'] │ [1,2] │
2. │ lol │ 7 │ ['a','b'] │ [3,4] │
└─────┴───────────┴─────────────┴─────────────┘
:) optimize table sums
:) select * from sums
┌─key─┬─sumOfSums─┬─sumsMap.key─┬─sumsMap.sum─┐
1. │ lol │ 10 │ ['a','b'] │ [4,6] │
└─────┴───────────┴─────────────┴─────────────┘
```
|
Workflow [PR], commit [45a93b6] Summary: ❌
|
|
I'm going to need some help with CI failures. Some performance builds failed to start, which doesn't seem related to these changes. Perhaps they just need a restart?
The addresses aren't symbolicated, so I'm not sure how to interpret this.
There are a few fuzzing things:
That stuff appears in other PRs too, so it seems unrelated to the changes here. It would be nice to restart the failed bits and get some guidance on whether there's something for me to fix otherwise. |
|
Failed tests are most likely unrelated to the changes, but let me check |
|
Stateless tests (amd_binary, old analyzer, s3 storage, DatabaseReplicated, parallel) - https://github.com/ClickHouse/ClickHouse/pull/91022/files |
ae74a95
Cherry pick #90927 to 25.3: Fix SummingMergeTree aggregation for Nested LowCardinality columns
…LowCardinality columns
Cherry pick #90927 to 25.8: Fix SummingMergeTree aggregation for Nested LowCardinality columns
…LowCardinality columns
Cherry pick #90927 to 25.9: Fix SummingMergeTree aggregation for Nested LowCardinality columns
…LowCardinality columns
Cherry pick #90927 to 25.10: Fix SummingMergeTree aggregation for Nested LowCardinality columns
… LowCardinality columns
Cherry pick #90927 to 25.11: Fix SummingMergeTree aggregation for Nested LowCardinality columns
… LowCardinality columns
Backport #90927 to 25.10: Fix SummingMergeTree aggregation for Nested LowCardinality columns
Backport #90927 to 25.11: Fix SummingMergeTree aggregation for Nested LowCardinality columns
Backport #90927 to 25.8: Fix SummingMergeTree aggregation for Nested LowCardinality columns
Backport #90927 to 25.9: Fix SummingMergeTree aggregation for Nested LowCardinality columns
Backport #90927 to 25.3: Fix SummingMergeTree aggregation for Nested LowCardinality columns
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixes
SummingMergeTreeaggregation forNestedLowCardinalitycolumnsDocumentation entry for user-facing changes
With
Stringwe see the expected behavior of theNestedcolumn:With
LowCardinality(String)before we see incorrect summing of theNestedcolumn:With this patch applied
LowCardinality(String)behaves exactly likeString, as it should: