Skip to content

Commit fa02f30

Browse files
committed
add a silly test
1 parent dad9464 commit fa02f30

File tree

3 files changed

+86
-3
lines changed

3 files changed

+86
-3
lines changed

src/Storages/StorageReplicatedMergeTree.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4458,6 +4458,7 @@ void StorageReplicatedMergeTree::exportMergeTreePartitionUpdatingTask()
44584458
}
44594459

44604460
export_merge_tree_partition_updating_task->scheduleAfter(30 * 1000);
4461+
export_merge_tree_partition_select_task->schedule();
44614462
}
44624463

44634464
void StorageReplicatedMergeTree::selectPartsToExport()
@@ -4838,9 +4839,6 @@ void StorageReplicatedMergeTree::selectPartsToExport()
48384839

48394840
}
48404841
});
4841-
4842-
/// managed to schedule a task, re-run immediately to pick up more tasks if possible
4843-
export_merge_tree_partition_select_task->schedule();
48444842
}
48454843
catch (...)
48464844
{
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Select from source table
3+
1 2020
4+
2 2020
5+
3 2020
6+
4 2021
7+
5 2021
8+
6 2022
9+
7 2022
10+
Select from destination table
11+
1 2020
12+
2 2020
13+
3 2020
14+
4 2021
15+
Export partition 2022
16+
Select from destination table again
17+
1 2020
18+
2 2020
19+
3 2020
20+
4 2021
21+
5 2021
22+
6 2022
23+
7 2022
24+
---- Data in roundtrip ReplicatedMergeTree table (should match s3_table)
25+
1 2020
26+
2 2020
27+
3 2020
28+
4 2021
29+
5 2021
30+
6 2022
31+
7 2022
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
# Tags: replica, no-parallel, no-replicated-database
3+
4+
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
5+
# shellcheck source=../shell_config.sh
6+
. "$CURDIR"/../shell_config.sh
7+
8+
rmt_table="rmt_table_${RANDOM}"
9+
s3_table="s3_table_${RANDOM}"
10+
rmt_table_roundtrip="rmt_table_roundtrip_${RANDOM}"
11+
12+
query() {
13+
$CLICKHOUSE_CLIENT --query "$1"
14+
}
15+
16+
query "DROP TABLE IF EXISTS $rmt_table, $s3_table, $rmt_table_roundtrip"
17+
18+
query "CREATE TABLE $rmt_table (id UInt64, year UInt16) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{database}/$rmt_table', 'replica1') PARTITION BY year ORDER BY tuple()"
19+
query "CREATE TABLE $s3_table (id UInt64, year UInt16) ENGINE = S3(s3_conn, filename='$s3_table', format=Parquet, partition_strategy='hive') PARTITION BY year"
20+
21+
query "INSERT INTO $rmt_table VALUES (1, 2020), (2, 2020), (4, 2021)"
22+
23+
query "INSERT INTO $rmt_table VALUES (3, 2020), (5, 2021)"
24+
25+
query "INSERT INTO $rmt_table VALUES (6, 2022), (7, 2022)"
26+
27+
query "ALTER TABLE $rmt_table EXPORT PARTITION ID '2020' TO TABLE $s3_table SETTINGS allow_experimental_export_merge_tree_part = 1"
28+
29+
query "ALTER TABLE $rmt_table EXPORT PARTITION ID '2021' TO TABLE $s3_table SETTINGS allow_experimental_export_merge_tree_part = 1"
30+
31+
# todo poll some kind of status
32+
sleep 15
33+
34+
echo "Select from source table"
35+
query "SELECT * FROM $rmt_table ORDER BY id"
36+
37+
echo "Select from destination table"
38+
query "SELECT * FROM $s3_table ORDER BY id"
39+
40+
echo "Export partition 2022"
41+
query "ALTER TABLE $rmt_table EXPORT PARTITION ID '2022' TO TABLE $s3_table SETTINGS allow_experimental_export_merge_tree_part = 1"
42+
43+
# todo poll some kind of status
44+
sleep 5
45+
46+
echo "Select from destination table again"
47+
query "SELECT * FROM $s3_table ORDER BY id"
48+
49+
query "CREATE TABLE $rmt_table_roundtrip ENGINE = ReplicatedMergeTree('/clickhouse/tables/{database}/$rmt_table_roundtrip', 'replica1') PARTITION BY year ORDER BY tuple() AS SELECT * FROM $s3_table"
50+
51+
echo "---- Data in roundtrip ReplicatedMergeTree table (should match s3_table)"
52+
query "SELECT * FROM $rmt_table_roundtrip ORDER BY id"
53+
54+
query "DROP TABLE IF EXISTS $rmt_table, $s3_table, $rmt_table_roundtrip"

0 commit comments

Comments
 (0)