ClickHouse/tests/queries/0_stateless/01232_preparing_sets_race_condition.sh

119 lines
3.0 KiB
Bash
Raw Normal View History

2020-04-07 17:59:13 +00:00
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
2020-12-28 11:46:53 +00:00
# shellcheck source=../shell_config.sh
2020-08-01 00:51:12 +00:00
. "$CURDIR"/../shell_config.sh
2020-04-07 17:59:13 +00:00
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
2020-08-01 00:40:56 +00:00
echo "
2020-04-07 17:59:13 +00:00
SELECT tableName
2020-08-01 00:40:56 +00:00
FROM
2020-04-07 17:59:13 +00:00
(
2020-08-01 00:40:56 +00:00
SELECT
col1,
'T1_notJoin1' AS tableName,
2020-04-07 17:59:13 +00:00
count(*) AS c
FROM tableA
GROUP BY col1
UNION ALL
2020-08-01 00:40:56 +00:00
SELECT
a.col1,
'T2_filteredAfterJoin1' AS tableName,
2020-04-07 17:59:13 +00:00
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
2020-08-01 00:40:56 +00:00
SELECT
a.col1,
'T3_filteredAfterJoin2' AS tableName,
2020-04-07 17:59:13 +00:00
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
2020-08-01 00:40:56 +00:00
SELECT
a.col1,
'T4_filteredBeforeJoin1' AS tableName,
2020-04-07 17:59:13 +00:00
count(*) AS c
FROM tableA AS a
2020-08-01 00:40:56 +00:00
INNER JOIN
2020-04-07 17:59:13 +00:00
(
2020-08-01 00:40:56 +00:00
SELECT
2020-04-07 17:59:13 +00:00
Aid
FROM tableB
WHERE colDate = '2020-01-01'
) AS b ON a.id = b.Aid
GROUP BY a.col1
UNION ALL
2020-08-01 00:40:56 +00:00
SELECT
a.col1,
'T5_filteredBeforeJoin2' AS tableName,
2020-04-07 17:59:13 +00:00
count(*) AS c
FROM tableA AS a
2020-08-01 00:40:56 +00:00
INNER JOIN
2020-04-07 17:59:13 +00:00
(
2020-08-01 00:40:56 +00:00
SELECT
2020-04-07 17:59:13 +00:00
Aid
FROM tableB
WHERE colDate = '2020-01-02'
) AS b ON a.id = b.Aid
GROUP BY a.col1
UNION ALL
2020-08-01 00:40:56 +00:00
SELECT
a.col1,
'T6_filteredAfterJoin3' AS tableName,
2020-04-07 17:59:13 +00:00
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
2020-08-01 00:40:56 +00:00
SELECT
col1,
'T7_notJoin2' AS tableName,
2020-04-07 17:59:13 +00:00
count(*) AS c
FROM tableA
GROUP BY col1
UNION ALL
2020-08-01 00:40:56 +00:00
SELECT
a.col1,
'T8_filteredBeforeJoin3' AS tableName,
2020-04-07 17:59:13 +00:00
count(*) AS c
FROM tableA AS a
2020-08-01 00:40:56 +00:00
INNER JOIN
2020-04-07 17:59:13 +00:00
(
2020-08-01 00:40:56 +00:00
SELECT
2020-04-07 17:59:13 +00:00
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;
2020-08-01 00:40:56 +00:00
" | $CLICKHOUSE_CLIENT -n | wc -l
2020-04-07 17:59:13 +00:00
echo "
DROP TABLE tableA;
DROP TABLE tableB;
" | $CLICKHOUSE_CLIENT -n