Skip to content

Commit aa99f36

Browse files
committed
add test for idempotent-copy and force copy
1 parent 160d6c8 commit aa99f36

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

tests/suites/1_stateful/00_copy/00_0000_copy_from_stage.result

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,27 @@ ontime_200.parquet
1010
199 2020.0 769
1111
199 2020.0 769
1212
199 2020.0 769
13+
199 2020.0 769
14+
199 2020.0 769
15+
199 2020.0 769
16+
199 2020.0 769
17+
199 2020.0 769
18+
796 2020.0 3076
1319
796 2020.0 3076
1420
199 2020.0 769
21+
199 2020.0 769
1522
ontime_200.parquet
1623
ontime_200_v1.parquet
1724
398 2020.0 1538
25+
398 2020.0 1538
26+
199 2020.0 769
1827
199 2020.0 769
1928
199 2020.0 769
2029
199 2020.0 769
30+
199 2020.0 769
31+
199 2020.0 769
32+
597 2020.0 2307
2133
597 2020.0 2307
2234
5
2335
0
36+
398 2020.0 769

tests/suites/1_stateful/00_copy/00_0000_copy_from_stage.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@ copy_from_stage_cases=(
3939
"copy into ontime200 from @s1 PATTERN = 'ontime.*ndjson$' FILE_FORMAT = (type = 'ndjson');"
4040
)
4141

42+
## Copy file twiice but return the same result to test idempotent-copy
4243
for i in "${copy_from_stage_cases[@]}"; do
4344
echo "$i" | $MYSQL_CLIENT_CONNECT
4445
echo "select count(1), avg(Year), sum(DayOfWeek) from ontime200" | $MYSQL_CLIENT_CONNECT
46+
echo "$i" | $MYSQL_CLIENT_CONNECT
47+
echo "select count(1), avg(Year), sum(DayOfWeek) from ontime200" | $MYSQL_CLIENT_CONNECT
4548
echo "truncate table ontime200" | $MYSQL_CLIENT_CONNECT
4649
done
4750

@@ -63,9 +66,12 @@ copy_from_named_external_stage_cases=(
6366
"copy into ontime200 from @named_external_stage FILES = ('ontime_200.csv.gz','ontime_200.csv.bz2','ontime_200.csv.zst') FILE_FORMAT = (type = 'CSV' field_delimiter = ',' compression = 'auto' record_delimiter = '\n' skip_header = 1);"
6467
)
6568

69+
## Copy file twiice but return the same result to test idempotent-copy
6670
for i in "${copy_from_named_external_stage_cases[@]}"; do
6771
echo "$i" | $MYSQL_CLIENT_CONNECT
6872
echo "select count(1), avg(Year), sum(DayOfWeek) from ontime200" | $MYSQL_CLIENT_CONNECT
73+
echo "$i" | $MYSQL_CLIENT_CONNECT
74+
echo "select count(1), avg(Year), sum(DayOfWeek) from ontime200" | $MYSQL_CLIENT_CONNECT
6975
echo "truncate table ontime200" | $MYSQL_CLIENT_CONNECT
7076
done
7177

@@ -82,6 +88,13 @@ echo $cmd | $MYSQL_CLIENT_CONNECT
8288
## list stage has metacache, so we just we aws client to ensure the data are purged
8389
aws --endpoint-url ${STORAGE_S3_ENDPOINT_URL} s3 ls s3://testbucket/admin/stage/s1/ | grep -o ontime_200.csv | wc -l
8490

91+
## copy with force=true
92+
echo "truncate table ontime200" | $MYSQL_CLIENT_CONNECT
93+
cmd="copy into ontime200 from @s1 PATTERN = 'ontime.*parquet$' FILE_FORMAT = (type = 'PARQUET') force=true;"
94+
echo $cmd | $MYSQL_CLIENT_CONNECT
95+
echo $cmd | $MYSQL_CLIENT_CONNECT
96+
echo "select count(1), avg(Year), sum(DayOfWeek) from ontime200" | $MYSQL_CLIENT_CONNECT
97+
8598
## Drop table.
8699
echo "drop table ontime200" | $MYSQL_CLIENT_CONNECT
87100
echo "drop stage if exists named_external_stage" | $MYSQL_CLIENT_CONNECT

0 commit comments

Comments
 (0)