Simplify reference file content

This commit is contained in:
JackyWoo 2023-08-29 20:42:59 +08:00
parent a8078b88ce
commit 51e64f6e4f
2 changed files with 16 additions and 53 deletions

View File

@ -1,9 +1,5 @@
-- { echoOn }
-- test simple distinct
SELECT uniq(a) FROM (SELECT DISTINCT a FROM test_rewrite_uniq_to_count) settings allow_experimental_analyzer=0;
1. test simple distinct
3
EXPLAIN SYNTAX SELECT uniq(a) FROM (SELECT DISTINCT a FROM test_rewrite_uniq_to_count) settings allow_experimental_analyzer=0;
SELECT count()
FROM
(
@ -11,9 +7,7 @@ FROM
FROM test_rewrite_uniq_to_count
)
SETTINGS allow_experimental_analyzer = 0
SELECT uniq(a) FROM (SELECT DISTINCT a FROM test_rewrite_uniq_to_count) settings allow_experimental_analyzer=1;
3
EXPLAIN QUERY TREE SELECT uniq(a) FROM (SELECT DISTINCT a FROM test_rewrite_uniq_to_count) settings allow_experimental_analyzer=1;
QUERY id: 0
PROJECTION COLUMNS
uniq(a) UInt64
@ -30,10 +24,8 @@ QUERY id: 0
JOIN TREE
TABLE id: 6, table_name: default.test_rewrite_uniq_to_count
SETTINGS allow_experimental_analyzer=1
-- test distinct with subquery alias
SELECT uniq(t.a) FROM (SELECT DISTINCT a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=0;
2. test distinct with subquery alias
3
EXPLAIN SYNTAX SELECT uniq(a) FROM (SELECT DISTINCT a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=0;
SELECT count()
FROM
(
@ -41,9 +33,7 @@ FROM
FROM test_rewrite_uniq_to_count
) AS t
SETTINGS allow_experimental_analyzer = 0
SELECT uniq(t.a) FROM (SELECT DISTINCT a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=1;
3
EXPLAIN QUERY TREE SELECT uniq(t.a) FROM (SELECT DISTINCT a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=1;
QUERY id: 0
PROJECTION COLUMNS
uniq(a) UInt64
@ -60,10 +50,8 @@ QUERY id: 0
JOIN TREE
TABLE id: 6, table_name: default.test_rewrite_uniq_to_count
SETTINGS allow_experimental_analyzer=1
-- test distinct with compound column name
SELECT uniq(a) FROM (SELECT DISTINCT test_rewrite_uniq_to_count.a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=0;
3. test distinct with compound column name
3
EXPLAIN SYNTAX SELECT uniq(a) FROM (SELECT DISTINCT test_rewrite_uniq_to_count.a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=0;
SELECT count()
FROM
(
@ -71,9 +59,7 @@ FROM
FROM test_rewrite_uniq_to_count
) AS t
SETTINGS allow_experimental_analyzer = 0
SELECT uniq(a) FROM (SELECT DISTINCT test_rewrite_uniq_to_count.a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=1;
3
EXPLAIN QUERY TREE SELECT uniq(a) FROM (SELECT DISTINCT test_rewrite_uniq_to_count.a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=1;
QUERY id: 0
PROJECTION COLUMNS
uniq(a) UInt64
@ -90,10 +76,8 @@ QUERY id: 0
JOIN TREE
TABLE id: 6, table_name: default.test_rewrite_uniq_to_count
SETTINGS allow_experimental_analyzer=1
-- test distinct with select expression alias
SELECT uniq(alias_of_a) FROM (SELECT DISTINCT a as alias_of_a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=0;
4. test distinct with select expression alias
3
EXPLAIN SYNTAX SELECT uniq(alias_of_a) FROM (SELECT DISTINCT a as alias_of_a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=0;
SELECT count()
FROM
(
@ -101,9 +85,7 @@ FROM
FROM test_rewrite_uniq_to_count
) AS t
SETTINGS allow_experimental_analyzer = 0
SELECT uniq(alias_of_a) FROM (SELECT DISTINCT a as alias_of_a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=1;
3
EXPLAIN QUERY TREE SELECT uniq(alias_of_a) FROM (SELECT DISTINCT a as alias_of_a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=1;
QUERY id: 0
PROJECTION COLUMNS
uniq(alias_of_a) UInt64
@ -120,10 +102,8 @@ QUERY id: 0
JOIN TREE
TABLE id: 6, table_name: default.test_rewrite_uniq_to_count
SETTINGS allow_experimental_analyzer=1
-- test simple group by
SELECT uniq(a) FROM (SELECT a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) settings allow_experimental_analyzer=0;
5. test simple group by
3
EXPLAIN SYNTAX SELECT uniq(a) FROM (SELECT a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) settings allow_experimental_analyzer=0;
SELECT count()
FROM
(
@ -134,9 +114,7 @@ FROM
GROUP BY a
)
SETTINGS allow_experimental_analyzer = 0
SELECT uniq(a) FROM (SELECT a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) settings allow_experimental_analyzer=1;
3
EXPLAIN QUERY TREE SELECT uniq(a) FROM (SELECT a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) settings allow_experimental_analyzer=1;
QUERY id: 0
PROJECTION COLUMNS
uniq(a) UInt64
@ -161,10 +139,8 @@ QUERY id: 0
LIST id: 10, nodes: 1
COLUMN id: 5, column_name: a, result_type: UInt8, source_id: 6
SETTINGS allow_experimental_analyzer=1
-- test group by with subquery alias
SELECT uniq(t.a) FROM (SELECT a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) t settings allow_experimental_analyzer=0;
6. test group by with subquery alias
3
EXPLAIN SYNTAX SELECT uniq(t.a) FROM (SELECT a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) t settings allow_experimental_analyzer=0;
SELECT count()
FROM
(
@ -175,9 +151,7 @@ FROM
GROUP BY a
) AS t
SETTINGS allow_experimental_analyzer = 0
SELECT uniq(t.a) FROM (SELECT a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) t settings allow_experimental_analyzer=1;
3
EXPLAIN QUERY TREE SELECT uniq(t.a) FROM (SELECT a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) t settings allow_experimental_analyzer=1;
QUERY id: 0
PROJECTION COLUMNS
uniq(a) UInt64
@ -202,10 +176,8 @@ QUERY id: 0
LIST id: 10, nodes: 1
COLUMN id: 5, column_name: a, result_type: UInt8, source_id: 6
SETTINGS allow_experimental_analyzer=1
-- test group by with compound column name
SELECT uniq(t.alias_of_a) FROM (SELECT a as alias_of_a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) t settings allow_experimental_analyzer=0;
7. test group by with compound column name
3
EXPLAIN SYNTAX SELECT uniq(t.alias_of_a) FROM (SELECT a as alias_of_a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) t settings allow_experimental_analyzer=0;
SELECT count()
FROM
(
@ -216,9 +188,7 @@ FROM
GROUP BY a
) AS t
SETTINGS allow_experimental_analyzer = 0
SELECT uniq(t.alias_of_a) FROM (SELECT a as alias_of_a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) t settings allow_experimental_analyzer=1;
3
EXPLAIN QUERY TREE SELECT uniq(t.alias_of_a) FROM (SELECT a as alias_of_a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) t settings allow_experimental_analyzer=1;
QUERY id: 0
PROJECTION COLUMNS
uniq(alias_of_a) UInt64
@ -243,10 +213,8 @@ QUERY id: 0
LIST id: 10, nodes: 1
COLUMN id: 5, column_name: a, result_type: UInt8, source_id: 6
SETTINGS allow_experimental_analyzer=1
-- test group by with select expression alias
SELECT uniq(t.alias_of_a) FROM (SELECT a as alias_of_a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY alias_of_a) t settings allow_experimental_analyzer=0;
8. test group by with select expression alias
3
EXPLAIN SYNTAX SELECT uniq(t.alias_of_a) FROM (SELECT a as alias_of_a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY alias_of_a) t settings allow_experimental_analyzer=0;
SELECT count()
FROM
(
@ -257,9 +225,7 @@ FROM
GROUP BY alias_of_a
) AS t
SETTINGS allow_experimental_analyzer = 0
SELECT uniq(t.alias_of_a) FROM (SELECT a as alias_of_a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY alias_of_a) t settings allow_experimental_analyzer=1;
3
EXPLAIN QUERY TREE SELECT uniq(t.alias_of_a) FROM (SELECT a as alias_of_a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY alias_of_a) t settings allow_experimental_analyzer=1;
QUERY id: 0
PROJECTION COLUMNS
uniq(alias_of_a) UInt64
@ -284,4 +250,3 @@ QUERY id: 0
LIST id: 10, nodes: 1
COLUMN id: 5, column_name: a, result_type: UInt8, source_id: 6
SETTINGS allow_experimental_analyzer=1
drop table if exists test_rewrite_uniq_to_count;

View File

@ -14,53 +14,52 @@ INSERT INTO test_rewrite_uniq_to_count values ('3', '3', '3'), ('3', '3', '3');
set optimize_uniq_to_count=true;
-- { echoOn }
-- test simple distinct
SELECT '1. test simple distinct';
SELECT uniq(a) FROM (SELECT DISTINCT a FROM test_rewrite_uniq_to_count) settings allow_experimental_analyzer=0;
EXPLAIN SYNTAX SELECT uniq(a) FROM (SELECT DISTINCT a FROM test_rewrite_uniq_to_count) settings allow_experimental_analyzer=0;
SELECT uniq(a) FROM (SELECT DISTINCT a FROM test_rewrite_uniq_to_count) settings allow_experimental_analyzer=1;
EXPLAIN QUERY TREE SELECT uniq(a) FROM (SELECT DISTINCT a FROM test_rewrite_uniq_to_count) settings allow_experimental_analyzer=1;
-- test distinct with subquery alias
SELECT '2. test distinct with subquery alias';
SELECT uniq(t.a) FROM (SELECT DISTINCT a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=0;
EXPLAIN SYNTAX SELECT uniq(a) FROM (SELECT DISTINCT a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=0;
SELECT uniq(t.a) FROM (SELECT DISTINCT a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=1;
EXPLAIN QUERY TREE SELECT uniq(t.a) FROM (SELECT DISTINCT a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=1;
-- test distinct with compound column name
SELECT '3. test distinct with compound column name';
SELECT uniq(a) FROM (SELECT DISTINCT test_rewrite_uniq_to_count.a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=0;
EXPLAIN SYNTAX SELECT uniq(a) FROM (SELECT DISTINCT test_rewrite_uniq_to_count.a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=0;
SELECT uniq(a) FROM (SELECT DISTINCT test_rewrite_uniq_to_count.a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=1;
EXPLAIN QUERY TREE SELECT uniq(a) FROM (SELECT DISTINCT test_rewrite_uniq_to_count.a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=1;
-- test distinct with select expression alias
SELECT '4. test distinct with select expression alias';
SELECT uniq(alias_of_a) FROM (SELECT DISTINCT a as alias_of_a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=0;
EXPLAIN SYNTAX SELECT uniq(alias_of_a) FROM (SELECT DISTINCT a as alias_of_a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=0;
SELECT uniq(alias_of_a) FROM (SELECT DISTINCT a as alias_of_a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=1;
EXPLAIN QUERY TREE SELECT uniq(alias_of_a) FROM (SELECT DISTINCT a as alias_of_a FROM test_rewrite_uniq_to_count) t settings allow_experimental_analyzer=1;
-- test simple group by
SELECT '5. test simple group by';
SELECT uniq(a) FROM (SELECT a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) settings allow_experimental_analyzer=0;
EXPLAIN SYNTAX SELECT uniq(a) FROM (SELECT a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) settings allow_experimental_analyzer=0;
SELECT uniq(a) FROM (SELECT a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) settings allow_experimental_analyzer=1;
EXPLAIN QUERY TREE SELECT uniq(a) FROM (SELECT a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) settings allow_experimental_analyzer=1;
-- test group by with subquery alias
SELECT '6. test group by with subquery alias';
SELECT uniq(t.a) FROM (SELECT a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) t settings allow_experimental_analyzer=0;
EXPLAIN SYNTAX SELECT uniq(t.a) FROM (SELECT a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) t settings allow_experimental_analyzer=0;
SELECT uniq(t.a) FROM (SELECT a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) t settings allow_experimental_analyzer=1;
EXPLAIN QUERY TREE SELECT uniq(t.a) FROM (SELECT a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) t settings allow_experimental_analyzer=1;
-- test group by with compound column name
SELECT '7. test group by with compound column name';
SELECT uniq(t.alias_of_a) FROM (SELECT a as alias_of_a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) t settings allow_experimental_analyzer=0;
EXPLAIN SYNTAX SELECT uniq(t.alias_of_a) FROM (SELECT a as alias_of_a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) t settings allow_experimental_analyzer=0;
SELECT uniq(t.alias_of_a) FROM (SELECT a as alias_of_a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) t settings allow_experimental_analyzer=1;
EXPLAIN QUERY TREE SELECT uniq(t.alias_of_a) FROM (SELECT a as alias_of_a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY a) t settings allow_experimental_analyzer=1;
-- test group by with select expression alias
SELECT '8. test group by with select expression alias';
SELECT uniq(t.alias_of_a) FROM (SELECT a as alias_of_a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY alias_of_a) t settings allow_experimental_analyzer=0;
EXPLAIN SYNTAX SELECT uniq(t.alias_of_a) FROM (SELECT a as alias_of_a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY alias_of_a) t settings allow_experimental_analyzer=0;
SELECT uniq(t.alias_of_a) FROM (SELECT a as alias_of_a, sum(b) FROM test_rewrite_uniq_to_count GROUP BY alias_of_a) t settings allow_experimental_analyzer=1;
@ -68,4 +67,3 @@ EXPLAIN QUERY TREE SELECT uniq(t.alias_of_a) FROM (SELECT a as alias_of_a, sum(b
drop table if exists test_rewrite_uniq_to_count;
-- { echoOff }