From 6f3b70009772e72db38a539b7937a5dde1f5d4d4 Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Tue, 7 Apr 2020 20:59:13 +0300 Subject: [PATCH] Added test. --- ...32_preparing_sets_race_condition.reference | 10 ++ .../01232_preparing_sets_race_condition.sh | 117 ++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 tests/queries/0_stateless/01232_preparing_sets_race_condition.reference create mode 100755 tests/queries/0_stateless/01232_preparing_sets_race_condition.sh diff --git a/tests/queries/0_stateless/01232_preparing_sets_race_condition.reference b/tests/queries/0_stateless/01232_preparing_sets_race_condition.reference new file mode 100644 index 00000000000..2fc36ed5c97 --- /dev/null +++ b/tests/queries/0_stateless/01232_preparing_sets_race_condition.reference @@ -0,0 +1,10 @@ +8 +8 +8 +8 +8 +8 +8 +8 +8 +8 diff --git a/tests/queries/0_stateless/01232_preparing_sets_race_condition.sh b/tests/queries/0_stateless/01232_preparing_sets_race_condition.sh new file mode 100755 index 00000000000..5f7b76c0e99 --- /dev/null +++ b/tests/queries/0_stateless/01232_preparing_sets_race_condition.sh @@ -0,0 +1,117 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +. $CURDIR/../shell_config.sh + +set -o errexit +set -o pipefail + + +echo " + DROP TABLE if exists tableA; + DROP TABLE if exists tableB; + + create table tableA (id UInt64, col1 UInt64, colDate Date) engine = ReplacingMergeTree(colDate, id, 8192); + create table tableB (id UInt64, Aid UInt64, colDate Date) engine = ReplacingMergeTree(colDate, id, 8192); + + insert into tableA select number, number % 10, addDays(toDate('2020-01-01'), - number % 1000) from numbers(100000); + insert into tableB select number, number % 100000, addDays(toDate('2020-01-01'), number % 90) from numbers(50000000); +" | $CLICKHOUSE_CLIENT -n + +for i in {1..10}; do echo " +SELECT tableName +FROM + ( + SELECT + col1, + 'T1_notJoin1' AS tableName, + count(*) AS c + FROM tableA + GROUP BY col1 + UNION ALL + SELECT + a.col1, + 'T2_filteredAfterJoin1' AS tableName, + count(*) AS c + FROM tableB AS b + INNER JOIN tableA AS a ON a.id = b.Aid + WHERE b.colDate = '2020-01-01' + GROUP BY a.col1 + UNION ALL + SELECT + a.col1, + 'T3_filteredAfterJoin2' AS tableName, + count(*) AS c + FROM tableB AS b + INNER JOIN + tableA AS a + ON a.id = b.Aid + WHERE b.colDate = '2020-01-02' + GROUP BY a.col1 + UNION ALL + SELECT + a.col1, + 'T4_filteredBeforeJoin1' AS tableName, + count(*) AS c + FROM tableA AS a + INNER JOIN + ( + SELECT + Aid + FROM tableB + WHERE colDate = '2020-01-01' + ) AS b ON a.id = b.Aid + GROUP BY a.col1 + UNION ALL + SELECT + a.col1, + 'T5_filteredBeforeJoin2' AS tableName, + count(*) AS c + FROM tableA AS a + INNER JOIN + ( + SELECT + Aid + FROM tableB + WHERE colDate = '2020-01-02' + ) AS b ON a.id = b.Aid + GROUP BY a.col1 + UNION ALL + SELECT + a.col1, + 'T6_filteredAfterJoin3' AS tableName, + count(*) AS c + FROM tableB AS b + INNER JOIN tableA AS a ON a.id = b.Aid + WHERE b.colDate = '2020-01-03' + GROUP BY a.col1 + UNION ALL + SELECT + col1, + 'T7_notJoin2' AS tableName, + count(*) AS c + FROM tableA + GROUP BY col1 + UNION ALL + SELECT + a.col1, + 'T8_filteredBeforeJoin3' AS tableName, + count(*) AS c + FROM tableA AS a + INNER JOIN + ( + SELECT + Aid + FROM tableB + WHERE colDate = '2020-01-03' + ) AS b ON a.id = b.Aid + GROUP BY a.col1 + ) AS a +GROUP BY tableName +ORDER BY tableName ASC; +" | $CLICKHOUSE_CLIENT -n | wc -l ; done; + +echo " + DROP TABLE tableA; + DROP TABLE tableB; +" | $CLICKHOUSE_CLIENT -n