Fix tests

This commit is contained in:
Igor Nikonov 2023-02-14 19:45:57 +00:00
parent fd2ebd6d77
commit c9b8e79684
4 changed files with 202 additions and 23 deletions

View File

@ -269,3 +269,133 @@ Expression (Project names)
ReadFromStorage (SystemNumbers)
-- execute
12
-- GROUP BY WITH ROLLUP before DISTINCT with on different columns => do _not_ remove DISTINCT
-- query
SELECT DISTINCT c
FROM
(
SELECT
a,
sum(b) AS c
FROM
(
SELECT
x.number AS a,
y.number AS b
FROM numbers(3) AS x, numbers(3, 3) AS y
)
GROUP BY a WITH ROLLUP
)
-- explain
Expression (Project names)
Distinct (DISTINCT)
Distinct (Preliminary DISTINCT)
Expression ((Projection + (Change column names to column identifiers + (Project names + Projection))))
Rollup
Aggregating
Expression ((Before GROUP BY + (Change column names to column identifiers + (Project names + (Projection + DROP unused columns after JOIN)))))
Join (JOIN FillRightFirst)
Expression (Change column names to column identifiers)
ReadFromStorage (SystemNumbers)
Expression (Change column names to column identifiers)
ReadFromStorage (SystemNumbers)
-- execute
12
36
-- GROUP BY WITH ROLLUP before DISTINCT with on the same columns => remove DISTINCT
-- query
SELECT DISTINCT a
FROM
(
SELECT
a,
sum(b) AS c
FROM
(
SELECT
x.number AS a,
y.number AS b
FROM numbers(3) AS x, numbers(3, 3) AS y
)
GROUP BY a WITH ROLLUP
)
-- explain
Expression ((Project names + (Projection + (Change column names to column identifiers + (Project names + Projection)))))
Rollup
Aggregating
Expression ((Before GROUP BY + (Change column names to column identifiers + (Project names + (Projection + DROP unused columns after JOIN)))))
Join (JOIN FillRightFirst)
Expression (Change column names to column identifiers)
ReadFromStorage (SystemNumbers)
Expression (Change column names to column identifiers)
ReadFromStorage (SystemNumbers)
-- execute
0
2
1
0
-- GROUP BY WITH CUBE before DISTINCT with on different columns => do _not_ remove DISTINCT
-- query
SELECT DISTINCT c
FROM
(
SELECT
a,
sum(b) AS c
FROM
(
SELECT
x.number AS a,
y.number AS b
FROM numbers(3) AS x, numbers(3, 3) AS y
)
GROUP BY a WITH CUBE
)
-- explain
Expression (Project names)
Distinct (DISTINCT)
Distinct (Preliminary DISTINCT)
Expression ((Projection + (Change column names to column identifiers + (Project names + Projection))))
Cube
Aggregating
Expression ((Before GROUP BY + (Change column names to column identifiers + (Project names + (Projection + DROP unused columns after JOIN)))))
Join (JOIN FillRightFirst)
Expression (Change column names to column identifiers)
ReadFromStorage (SystemNumbers)
Expression (Change column names to column identifiers)
ReadFromStorage (SystemNumbers)
-- execute
12
36
-- GROUP BY WITH CUBE before DISTINCT with on the same columns => remove DISTINCT
-- query
SELECT DISTINCT a
FROM
(
SELECT
a,
sum(b) AS c
FROM
(
SELECT
x.number AS a,
y.number AS b
FROM numbers(3) AS x, numbers(3, 3) AS y
)
GROUP BY a WITH CUBE
)
-- explain
Expression ((Project names + (Projection + (Change column names to column identifiers + (Project names + Projection)))))
Cube
Aggregating
Expression ((Before GROUP BY + (Change column names to column identifiers + (Project names + (Projection + DROP unused columns after JOIN)))))
Join (JOIN FillRightFirst)
Expression (Change column names to column identifiers)
ReadFromStorage (SystemNumbers)
Expression (Change column names to column identifiers)
ReadFromStorage (SystemNumbers)
-- execute
0
2
1
0

View File

@ -148,3 +148,75 @@ FROM
GROUP BY a
)"
run_query "$query"
echo "-- GROUP BY WITH ROLLUP before DISTINCT with on different columns => do _not_ remove DISTINCT"
query="SELECT DISTINCT c
FROM
(
SELECT
a,
sum(b) AS c
FROM
(
SELECT
x.number AS a,
y.number AS b
FROM numbers(3) AS x, numbers(3, 3) AS y
)
GROUP BY a WITH ROLLUP
)"
run_query "$query"
echo "-- GROUP BY WITH ROLLUP before DISTINCT with on the same columns => remove DISTINCT"
query="SELECT DISTINCT a
FROM
(
SELECT
a,
sum(b) AS c
FROM
(
SELECT
x.number AS a,
y.number AS b
FROM numbers(3) AS x, numbers(3, 3) AS y
)
GROUP BY a WITH ROLLUP
)"
run_query "$query"
echo "-- GROUP BY WITH CUBE before DISTINCT with on different columns => do _not_ remove DISTINCT"
query="SELECT DISTINCT c
FROM
(
SELECT
a,
sum(b) AS c
FROM
(
SELECT
x.number AS a,
y.number AS b
FROM numbers(3) AS x, numbers(3, 3) AS y
)
GROUP BY a WITH CUBE
)"
run_query "$query"
echo "-- GROUP BY WITH CUBE before DISTINCT with on the same columns => remove DISTINCT"
query="SELECT DISTINCT a
FROM
(
SELECT
a,
sum(b) AS c
FROM
(
SELECT
x.number AS a,
y.number AS b
FROM numbers(3) AS x, numbers(3, 3) AS y
)
GROUP BY a WITH CUBE
)"
run_query "$query"

View File

@ -1,23 +0,0 @@
-- Tags: distributed
SET allow_experimental_analyzer=0;
set optimize_duplicate_order_by_and_distinct = 0;
SET distributed_group_by_no_merge = 0;
SELECT DISTINCT number
FROM
(
SELECT DISTINCT number
FROM remote('127.0.0.{1,2}', system.numbers)
LIMIT 1
SETTINGS distributed_group_by_no_merge = 1
);
SET distributed_group_by_no_merge = 1;
SELECT DISTINCT number
FROM
(
SELECT DISTINCT number
FROM remote('127.0.0.{1,2}', system.numbers)
LIMIT 1
);