mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-10 16:32:12 +00:00
dea1706d4e
* Fix GROUP BY AggregateFunction finalizeChunk() was unconditionally converting AggregateFunction to the underlying type, however this should be done only if the aggregate was applied. So pass names of aggregates as an argument to the finalizeChunk() Fuzzer report [1]: Logical error: 'Bad cast from type DB::ColumnArray to DB::ColumnAggregateFunction'. Received signal 6 Received signal Aborted (6) For the following query: SELECT arraySort(groupArrayArray(grp_simple)), grp_aggreg, arraySort(groupArrayArray(grp_simple)), b, arraySort(groupArrayArray(grp_simple)) AS grs FROM data_02294 GROUP BY a, grp_aggreg, b SETTINGS optimize_aggregation_in_order = 1 [1]: https://s3.amazonaws.com/clickhouse-test-reports/37050/323ae98202d80fc4b311be1e7308ef2ac39e6063/fuzzer_astfuzzerdebug,actions//fuzzer.log v2: fix conflicts in src/Interpreters/InterpreterSelectQuery.cpp v3: Fix header for GROUP BY AggregateFunction WITH TOTALS v4: Add sanity check into finalizeBlock() v5: Use typeid_cast<&> to get more sensible error in case of bad cast (as suggested by @nickitat) v6: Fix positions passed to finalizeChunk() Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com> * Core/ColumnNumbers.h: remove unused <string> Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com> * Optimize finalizeChunk()/finalizeBlock() v2: s/ByPosition/Mask/ s/by_position/mask/ Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
31 lines
2.1 KiB
Plaintext
31 lines
2.1 KiB
Plaintext
-- { echoOn }
|
|
SELECT grp_aggreg FROM data_02295 GROUP BY a, grp_aggreg SETTINGS optimize_aggregation_in_order = 0 FORMAT JSONEachRow;
|
|
{"grp_aggreg":"\u0002\u0002\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0003\u0000\u0000\u0000\u0000\u0000\u0000\u0000"}
|
|
{"grp_aggreg":"\u0002\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0000"}
|
|
SELECT grp_aggreg FROM data_02295 GROUP BY a, grp_aggreg SETTINGS optimize_aggregation_in_order = 1 FORMAT JSONEachRow;
|
|
{"grp_aggreg":"\u0002\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0000"}
|
|
{"grp_aggreg":"\u0002\u0002\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0003\u0000\u0000\u0000\u0000\u0000\u0000\u0000"}
|
|
SELECT grp_aggreg FROM data_02295 GROUP BY a, grp_aggreg WITH TOTALS SETTINGS optimize_aggregation_in_order = 0 FORMAT JSONEachRow;
|
|
{"grp_aggreg":"\u0002\u0002\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0003\u0000\u0000\u0000\u0000\u0000\u0000\u0000"}
|
|
{"grp_aggreg":"\u0002\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0000"}
|
|
SELECT grp_aggreg FROM data_02295 GROUP BY a, grp_aggreg WITH TOTALS SETTINGS optimize_aggregation_in_order = 1 FORMAT JSONEachRow;
|
|
{"grp_aggreg":"\u0002\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0000"}
|
|
{"grp_aggreg":"\u0002\u0002\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0003\u0000\u0000\u0000\u0000\u0000\u0000\u0000"}
|
|
-- regression for incorrect positions passed to finalizeChunk()
|
|
SELECT a, min(b), max(b) FROM data_02295 GROUP BY a ORDER BY a, count() SETTINGS optimize_aggregation_in_order = 1;
|
|
0 0 0
|
|
1 0 0
|
|
SELECT a, min(b), max(b) FROM data_02295 GROUP BY a ORDER BY a, count() SETTINGS optimize_aggregation_in_order = 1, max_threads = 1;
|
|
0 0 0
|
|
1 0 0
|
|
SELECT a, min(b), max(b) FROM data_02295 GROUP BY a WITH TOTALS ORDER BY a, count() SETTINGS optimize_aggregation_in_order = 1;
|
|
0 0 0
|
|
1 0 0
|
|
|
|
0 0 0
|
|
SELECT a, min(b), max(b) FROM data_02295 GROUP BY a WITH TOTALS ORDER BY a, count() SETTINGS optimize_aggregation_in_order = 1, max_threads = 1;
|
|
0 0 0
|
|
1 0 0
|
|
|
|
0 0 0
|