ClickHouse/tests/queries/0_stateless/01883_grouping_sets_crash.reference
Azat Khuzhin 8a224239c1 Prohibit optimize_aggregation_in_order with GROUPING SETS
AggregatingStep ignores it anyway, and it leads to the following error
in getSortDescriptionFromGroupBy(), like in [1]:

    2022.05.24 04:29:29.279431 [ 3395 ] {26543564-8bc8-4a3a-b984-70a2adf0245d} <Fatal> : Logical error: 'Trying to get name of not a column: ExpressionList'.

  [1]: https://s3.amazonaws.com/clickhouse-test-reports/36914/67d3ac72d26ab74d69f03c03422349d4faae9e19/stateless_tests__ubsan__actions_.html

v2: revert change to getSortDescriptionFromGroupBy() after
    GroupingSetsRewriterVisitor had been introduced
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2022-05-27 17:44:57 +03:00

361 lines
4.7 KiB
Plaintext

-- { echoOn }
SELECT
fact_3_id,
fact_4_id
FROM grouping_sets
GROUP BY
GROUPING SETS (
('wo\0ldworldwo\0ldworld'),
(fact_3_id, fact_4_id))
ORDER BY
fact_3_id, fact_4_id;
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
SELECT 'SECOND QUERY:';
SECOND QUERY:
SELECT
fact_3_id,
fact_4_id
FROM grouping_sets
GROUP BY
GROUPING SETS (
(fact_1_id, fact_2_id),
((-9223372036854775808, NULL, (tuple(1.), (tuple(1.), 1048576), 65535))),
((tuple(3.4028234663852886e38), (tuple(1024), -2147483647), NULL)),
(fact_3_id, fact_4_id))
ORDER BY
(NULL, ('256', (tuple(NULL), NULL), NULL, NULL), NULL) ASC,
fact_1_id DESC NULLS FIRST,
fact_2_id DESC NULLS FIRST,
fact_4_id ASC;
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
SELECT 'THIRD QUERY:';
THIRD QUERY:
SELECT
extractAllGroups(NULL, 'worldworldworldwo\0ldworldworldworldwo\0ld'),
fact_2_id,
fact_3_id,
fact_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0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
\N 0 0 0
SELECT fact_3_id
FROM grouping_sets
GROUP BY
GROUPING SETS ((fact_3_id, fact_4_id))
ORDER BY fact_3_id ASC;
1
2
3
4
5
6
7
8
9
10
-- Following two queries were fuzzed
SELECT 'w\0\0ldworldwo\0l\0world'
FROM grouping_sets
GROUP BY
GROUPING SETS (
( fact_4_id),
( NULL),
( fact_3_id, fact_4_id))
ORDER BY
NULL ASC,
NULL DESC NULLS FIRST,
fact_3_id ASC,
fact_3_id ASC NULLS LAST,
'wo\0ldworldwo\0ldworld' ASC NULLS LAST,
'w\0\0ldworldwo\0l\0world' DESC NULLS FIRST,
'wo\0ldworldwo\0ldworld' ASC,
NULL ASC NULLS FIRST,
fact_4_id DESC NULLS LAST;
w\0\0ldworldwo\0l\0world
w\0\0ldworldwo\0l\0world
w\0\0ldworldwo\0l\0world
w\0\0ldworldwo\0l\0world
w\0\0ldworldwo\0l\0world
w\0\0ldworldwo\0l\0world
w\0\0ldworldwo\0l\0world
w\0\0ldworldwo\0l\0world
w\0\0ldworldwo\0l\0world
w\0\0ldworldwo\0l\0world
w\0\0ldworldwo\0l\0world
w\0\0ldworldwo\0l\0world
w\0\0ldworldwo\0l\0world
w\0\0ldworldwo\0l\0world
w\0\0ldworldwo\0l\0world
w\0\0ldworldwo\0l\0world
w\0\0ldworldwo\0l\0world
w\0\0ldworldwo\0l\0world
w\0\0ldworldwo\0l\0world
w\0\0ldworldwo\0l\0world
w\0\0ldworldwo\0l\0world
SELECT fact_3_id
FROM grouping_sets
GROUP BY
GROUPING SETS (
( 'wo\0ldworldwo\0ldworldwo\0ldworldwo\0ldworldwo\0ldworldwo\0ldworldwo\0ldworldwo\0ldworld'),
( NULL),
( fact_4_id),
( fact_3_id, fact_4_id))
ORDER BY fact_3_id ASC NULLS FIRST;
0
0
0
0
0
0
0
0
0
0
0
0
1
2
3
4
5
6
7
8
9
10
SELECT fact_3_id, fact_4_id, count()
FROM grouping_sets
GROUP BY
GROUPING SETS (
( fact_3_id, fact_4_id))
ORDER BY fact_3_id, fact_4_id
SETTINGS optimize_aggregation_in_order=1;
1 1 100
2 2 100
3 3 100
4 4 100
5 5 100
6 6 100
7 7 100
8 8 100
9 9 100
10 10 100
SELECT fact_3_id, fact_4_id, count()
FROM grouping_sets
GROUP BY
GROUPING SETS (
fact_3_id,
fact_4_id)
ORDER BY fact_3_id, fact_4_id
SETTINGS optimize_aggregation_in_order=1;
0 1 100
0 2 100
0 3 100
0 4 100
0 5 100
0 6 100
0 7 100
0 8 100
0 9 100
0 10 100
1 0 100
2 0 100
3 0 100
4 0 100
5 0 100
6 0 100
7 0 100
8 0 100
9 0 100
10 0 100
SELECT fact_3_id, fact_4_id, count()
FROM grouping_sets
GROUP BY
GROUPING SETS (
( fact_3_id ),
( fact_3_id, fact_4_id))
ORDER BY fact_3_id, fact_4_id
SETTINGS optimize_aggregation_in_order=1;
1 0 100
1 1 100
2 0 100
2 2 100
3 0 100
3 3 100
4 0 100
4 4 100
5 0 100
5 5 100
6 0 100
6 6 100
7 0 100
7 7 100
8 0 100
8 8 100
9 0 100
9 9 100
10 0 100
10 10 100