Skip to content

Commit

Permalink
Merge pull request #4720 from sundy-li/tests-improve
Browse files Browse the repository at this point in the history
query(tests): improve tests
  • Loading branch information
BohuTANG authored Apr 6, 2022
2 parents 515591d + c11b44d commit b0f90cc
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,5 @@
1
1
1 1 1 1
2022-04-02 15:10:28 2022-04-02 15:10:28.000
2022-04-02 15:10:28 2022-04-02 15:10:28.221
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,11 @@ insert into ts values(now(), now(), today(), today());
select toDateTime64(a) = toDateTime64(b), toDateTime32(a) = toDateTime(b), toDate32(c) = toDate32(d), toDate(c) = toDate(d) from ts;
drop table if exists ts;


create table t(d32 datetime32, d64 datetime64);

insert into t values('2022-04-02 15:10:28', '2022-04-02 15:10:28');
insert into t values('2022-04-02 15:10:28.221', '2022-04-02 15:10:28.221');

select * from t order by d64;
drop table t;
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,3 @@ Test copy from file
398 2020 1538
398 2020 1538
398 2020 1538
ontime_200.csv
ontime_200.parquet
199 2020 769
ontime_200.parquet
ontime_200_v1.parquet
398 2020 1538
25 changes: 1 addition & 24 deletions tests/suites/1_stateful/00_copy/00_0000_copy_from_s3_location.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,6 @@ echo "truncate table ontime200" | $MYSQL_CLIENT_CONNECT
echo "copy into ontime200 from 's3://testbucket/admin/data/' credentials=(aws_key_id='minioadmin' aws_secret_key='minioadmin') PATTERN = 'ontime.*parquet' FILE_FORMAT = (type = 'PARQUET')" | $MYSQL_CLIENT_CONNECT
echo "select count(1), avg(Year), sum(DayOfWeek) from ontime200" | $MYSQL_CLIENT_CONNECT
echo "truncate table ontime200" | $MYSQL_CLIENT_CONNECT
echo "drop table if exists ontime200;" | $MYSQL_CLIENT_CONNECT



aws --endpoint-url http://127.0.0.1:9900/ s3 cp s3://testbucket/admin/data/ontime_200.csv s3://testbucket/admin/stage/s1/ontime_200.csv > /dev/null 2>&1
aws --endpoint-url http://127.0.0.1:9900/ s3 cp s3://testbucket/admin/data/ontime_200.parquet s3://testbucket/admin/stage/s1/ontime_200.parquet > /dev/null 2>&1


echo "CREATE STAGE s1;" | $MYSQL_CLIENT_CONNECT
echo "list @s1 PATTERN = 'ontime.*'" | $MYSQL_CLIENT_CONNECT
echo "copy into ontime200 from '@s1' PATTERN = 'ontime.*parquet' FILE_FORMAT = (type = 'PARQUET');" | $MYSQL_CLIENT_CONNECT
echo "select count(1), avg(Year), sum(DayOfWeek) from ontime200" | $MYSQL_CLIENT_CONNECT
echo "truncate table ontime200" | $MYSQL_CLIENT_CONNECT


## Copy from named external stage
echo "CREATE STAGE named_external_stage url = 's3://testbucket/admin/data/' credentials=(aws_key_id='minioadmin' aws_secret_key='minioadmin');" | $MYSQL_CLIENT_CONNECT
echo "list @named_external_stage PATTERN = 'ontime.*parquet'" | $MYSQL_CLIENT_CONNECT
echo "copy into ontime200 from '@named_external_stage' PATTERN = 'ontime.*parquet' FILE_FORMAT = (type = 'PARQUET')" | $MYSQL_CLIENT_CONNECT
echo "select count(1), avg(Year), sum(DayOfWeek) from ontime200" | $MYSQL_CLIENT_CONNECT
echo "truncate table ontime200" | $MYSQL_CLIENT_CONNECT


## Drop table.
echo "drop table ontime200" | $MYSQL_CLIENT_CONNECT
echo "drop stage if exists named_external_stage" | $MYSQL_CLIENT_CONNECT
echo "drop stage if exists s1" | $MYSQL_CLIENT_CONNECT
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ontime_200.csv
ontime_200.parquet
199 2020 769
ontime_200.parquet
ontime_200_v1.parquet
398 2020 1538
34 changes: 34 additions & 0 deletions tests/suites/1_stateful/00_copy/00_0000_copy_from_stage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. "$CURDIR"/../../../shell_env.sh

echo "drop table if exists ontime200;" | $MYSQL_CLIENT_CONNECT
## Create table
cat $CURDIR/../ontime/create_table.sql | sed 's/ontime/ontime200/g' | $MYSQL_CLIENT_CONNECT


aws --endpoint-url http://127.0.0.1:9900/ s3 cp s3://testbucket/admin/data/ontime_200.csv s3://testbucket/admin/stage/s1/ontime_200.csv > /dev/null 2>&1
aws --endpoint-url http://127.0.0.1:9900/ s3 cp s3://testbucket/admin/data/ontime_200.parquet s3://testbucket/admin/stage/s1/ontime_200.parquet > /dev/null 2>&1


echo "CREATE STAGE s1;" | $MYSQL_CLIENT_CONNECT
echo "list @s1 PATTERN = 'ontime.*'" | $MYSQL_CLIENT_CONNECT
echo "copy into ontime200 from '@s1' PATTERN = 'ontime.*parquet' FILE_FORMAT = (type = 'PARQUET');" | $MYSQL_CLIENT_CONNECT
echo "select count(1), avg(Year), sum(DayOfWeek) from ontime200" | $MYSQL_CLIENT_CONNECT
echo "truncate table ontime200" | $MYSQL_CLIENT_CONNECT


## Copy from named external stage
echo "CREATE STAGE named_external_stage url = 's3://testbucket/admin/data/' credentials=(aws_key_id='minioadmin' aws_secret_key='minioadmin');" | $MYSQL_CLIENT_CONNECT
echo "list @named_external_stage PATTERN = 'ontime.*parquet'" | $MYSQL_CLIENT_CONNECT
echo "copy into ontime200 from '@named_external_stage' PATTERN = 'ontime.*parquet' FILE_FORMAT = (type = 'PARQUET')" | $MYSQL_CLIENT_CONNECT
echo "select count(1), avg(Year), sum(DayOfWeek) from ontime200" | $MYSQL_CLIENT_CONNECT
echo "truncate table ontime200" | $MYSQL_CLIENT_CONNECT


## Drop table.
echo "drop table ontime200" | $MYSQL_CLIENT_CONNECT
echo "drop stage if exists named_external_stage" | $MYSQL_CLIENT_CONNECT
echo "drop stage if exists s1" | $MYSQL_CLIENT_CONNECT

0 comments on commit b0f90cc

Please sign in to comment.