From 8f60f8556d27bcc63d263178c99f3f4bdd9c1b23 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Wed, 19 Jun 2024 11:10:18 +0000 Subject: [PATCH 1/2] Backport #65379 to 24.3: Fix alignment of Distinct combinator --- .../Combinators/AggregateFunctionDistinct.h | 5 +++++ .../03173_distinct_combinator_alignment.reference | 0 .../0_stateless/03173_distinct_combinator_alignment.sql | 1 + 3 files changed, 6 insertions(+) create mode 100644 tests/queries/0_stateless/03173_distinct_combinator_alignment.reference create mode 100644 tests/queries/0_stateless/03173_distinct_combinator_alignment.sql diff --git a/src/AggregateFunctions/Combinators/AggregateFunctionDistinct.h b/src/AggregateFunctions/Combinators/AggregateFunctionDistinct.h index 4338dcff5c0..f532858b3d8 100644 --- a/src/AggregateFunctions/Combinators/AggregateFunctionDistinct.h +++ b/src/AggregateFunctions/Combinators/AggregateFunctionDistinct.h @@ -228,6 +228,11 @@ public: return prefix_size + nested_func->sizeOfData(); } + size_t alignOfData() const override + { + return std::max(alignof(Data), nested_func->alignOfData()); + } + void create(AggregateDataPtr __restrict place) const override { new (place) Data; diff --git a/tests/queries/0_stateless/03173_distinct_combinator_alignment.reference b/tests/queries/0_stateless/03173_distinct_combinator_alignment.reference new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/queries/0_stateless/03173_distinct_combinator_alignment.sql b/tests/queries/0_stateless/03173_distinct_combinator_alignment.sql new file mode 100644 index 00000000000..4a066be5086 --- /dev/null +++ b/tests/queries/0_stateless/03173_distinct_combinator_alignment.sql @@ -0,0 +1 @@ +SELECT toTypeName(topKDistinctState(toNullable(10))(toString(number)) IGNORE NULLS) FROM numbers(100) GROUP BY tuple((map((materialize(toNullable(1)), 2), 4, (3, 4), 5), 3)), map((1, 2), 4, (3, 4), toNullable(5)) WITH CUBE WITH TOTALS FORMAT Null From dcd2c61bd379df0801a7d6651cde8424ffe6a2c7 Mon Sep 17 00:00:00 2001 From: Antonio Andelic Date: Mon, 24 Jun 2024 11:39:22 +0100 Subject: [PATCH 2/2] Remove test --- .../0_stateless/03173_distinct_combinator_alignment.reference | 0 .../queries/0_stateless/03173_distinct_combinator_alignment.sql | 1 - 2 files changed, 1 deletion(-) delete mode 100644 tests/queries/0_stateless/03173_distinct_combinator_alignment.reference delete mode 100644 tests/queries/0_stateless/03173_distinct_combinator_alignment.sql diff --git a/tests/queries/0_stateless/03173_distinct_combinator_alignment.reference b/tests/queries/0_stateless/03173_distinct_combinator_alignment.reference deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/queries/0_stateless/03173_distinct_combinator_alignment.sql b/tests/queries/0_stateless/03173_distinct_combinator_alignment.sql deleted file mode 100644 index 4a066be5086..00000000000 --- a/tests/queries/0_stateless/03173_distinct_combinator_alignment.sql +++ /dev/null @@ -1 +0,0 @@ -SELECT toTypeName(topKDistinctState(toNullable(10))(toString(number)) IGNORE NULLS) FROM numbers(100) GROUP BY tuple((map((materialize(toNullable(1)), 2), 4, (3, 4), 5), 3)), map((1, 2), 4, (3, 4), toNullable(5)) WITH CUBE WITH TOTALS FORMAT Null