Skip to content

Commit 6bc7c09

Browse files
committed
add roundtrip check
1 parent 2506663 commit 6bc7c09

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

src/Storages/StorageMergeTree.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,9 @@ void StorageMergeTree::exportPartitionToTable(const PartitionCommand & command,
630630
}
631631
else
632632
{
633-
exportPartsImpl(exports_tagger, transaction_id, dest_storage);
634-
635-
commitExportPartitionTask(manifest, dest_storage, getContext());
633+
/// always in the background for now. I need to sort out the locks
634+
background_moves_assignee.scheduleMoveTask(
635+
std::make_shared<ExecutableLambdaAdapter>(export_partition_function, moves_assignee_trigger, getStorageID()));
636636
}
637637
}
638638

tests/queries/0_stateless/03572_export_mt_part_to_object_storage.reference

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,11 @@ test/s3_table_NAME/year=2020/SNOWFLAKE_ID.parquet 3 2020
2323
test/s3_table_NAME/year=2021/SNOWFLAKE_ID.parquet 4 2021
2424
test/s3_table_NAME/year=2020/SNOWFLAKE_ID.parquet 5 2020
2525
test/s3_table_NAME/year=2020/SNOWFLAKE_ID.parquet 6 2020
26+
---- Round trip check: create a new MergeTree table as SELECT * from s3_table
27+
---- Data in roundtrip MergeTree table (should match s3_table)
28+
1 2020
29+
2 2020
30+
3 2020
31+
4 2021
32+
5 2020
33+
6 2020

tests/queries/0_stateless/03572_export_mt_part_to_object_storage.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
66

77
mt_table="mt_table_${RANDOM}"
88
s3_table="s3_table_${RANDOM}"
9+
mt_table_roundtrip="mt_table_roundtrip_${RANDOM}"
910

1011
query() {
1112
$CLICKHOUSE_CLIENT --query "$1"
1213
}
1314

14-
query "DROP TABLE IF EXISTS $mt_table, $s3_table"
15+
query "DROP TABLE IF EXISTS $mt_table, $s3_table, $mt_table_roundtrip"
1516

1617
query "CREATE TABLE $mt_table (id UInt64, year UInt16) ENGINE = MergeTree() PARTITION BY year ORDER BY tuple()"
1718
query "CREATE TABLE $s3_table (id UInt64, year UInt16) ENGINE = S3(s3_conn, filename='$s3_table', format=Parquet, partition_strategy='hive') PARTITION BY year"
@@ -41,5 +42,12 @@ query "ALTER TABLE $mt_table EXPORT PARTITION ID '2021' TO TABLE $s3_table SETTI
4142
echo "---- Assert both partitions are there"
4243
query "SELECT DISTINCT ON (id) replaceRegexpAll(replaceRegexpAll(_path, '$s3_table', 's3_table_NAME'), '[^/]+\\.parquet', 'SNOWFLAKE_ID.parquet'), * FROM $s3_table ORDER BY id"
4344

45+
echo "---- Round trip check: create a new MergeTree table as SELECT * from s3_table"
46+
47+
query "CREATE TABLE $mt_table_roundtrip ENGINE = MergeTree() PARTITION BY year ORDER BY tuple() AS SELECT * FROM $s3_table"
48+
49+
echo "---- Data in roundtrip MergeTree table (should match s3_table)"
50+
query "SELECT DISTINCT ON (id) * FROM $mt_table_roundtrip ORDER BY id"
51+
4452
query "SYSTEM START MERGES"
45-
query "DROP TABLE IF EXISTS $mt_table, $s3_table"
53+
query "DROP TABLE IF EXISTS $mt_table, $s3_table, $mt_table_roundtrip"

0 commit comments

Comments
 (0)