Skip to content

Commit 8d8bcb8

Browse files
committed
chore(ci): add script to load tpch100
1 parent 12f187c commit 8d8bcb8

File tree

3 files changed

+138
-0
lines changed

3 files changed

+138
-0
lines changed

.github/workflows/dev-linux.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
- "docker/**"
1212
- "scripts/setup/**"
1313
- ".devcontainer/**"
14+
merge_group:
15+
types:
16+
- checks_requested
1417

1518
concurrency:
1619
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
cat <<SQL | bendsql query
6+
select version();
7+
SQL
8+
9+
for t in customer lineitem nation orders partsupp part region supplier; do
10+
echo "DROP TABLE IF EXISTS $t;" | bendsql query
11+
done
12+
13+
cat <<SQL | bendsql query
14+
CREATE TABLE IF NOT EXISTS customer (
15+
c_custkey BIGINT not null,
16+
c_name STRING not null,
17+
c_address STRING not null,
18+
c_nationkey INTEGER not null,
19+
c_phone STRING not null,
20+
c_acctbal DECIMAL(15, 2) not null,
21+
c_mktsegment STRING not null,
22+
c_comment STRING not null
23+
) CLUSTER BY (c_custkey);
24+
SQL
25+
26+
cat <<SQL | bendsql query
27+
CREATE TABLE IF NOT EXISTS lineitem (
28+
l_orderkey BIGINT not null,
29+
l_partkey BIGINT not null,
30+
l_suppkey BIGINT not null,
31+
l_linenumber BIGINT not null,
32+
l_quantity DECIMAL(15, 2) not null,
33+
l_extendedprice DECIMAL(15, 2) not null,
34+
l_discount DECIMAL(15, 2) not null,
35+
l_tax DECIMAL(15, 2) not null,
36+
l_returnflag STRING not null,
37+
l_linestatus STRING not null,
38+
l_shipdate DATE not null,
39+
l_commitdate DATE not null,
40+
l_receiptdate DATE not null,
41+
l_shipinstruct STRING not null,
42+
l_shipmode STRING not null,
43+
l_comment STRING not null
44+
) CLUSTER BY(l_shipdate, l_orderkey);
45+
SQL
46+
47+
# create tpch tables
48+
cat <<SQL | bendsql query
49+
CREATE TABLE IF NOT EXISTS nation (
50+
n_nationkey INTEGER not null,
51+
n_name STRING not null,
52+
n_regionkey INTEGER not null,
53+
n_comment STRING
54+
) CLUSTER BY (n_nationkey);
55+
SQL
56+
57+
cat <<SQL | bendsql query
58+
CREATE TABLE IF NOT EXISTS orders (
59+
o_orderkey BIGINT not null,
60+
o_custkey BIGINT not null,
61+
o_orderstatus STRING not null,
62+
o_totalprice DECIMAL(15, 2) not null,
63+
o_orderdate DATE not null,
64+
o_orderpriority STRING not null,
65+
o_clerk STRING not null,
66+
o_shippriority INTEGER not null,
67+
o_comment STRING not null
68+
) CLUSTER BY (o_orderkey, o_orderdate);
69+
SQL
70+
71+
cat <<SQL | bendsql query
72+
CREATE TABLE IF NOT EXISTS partsupp (
73+
ps_partkey BIGINT not null,
74+
ps_suppkey BIGINT not null,
75+
ps_availqty BIGINT not null,
76+
ps_supplycost DECIMAL(15, 2) not null,
77+
ps_comment STRING not null
78+
) CLUSTER BY (ps_partkey);
79+
SQL
80+
81+
cat <<SQL | bendsql query
82+
CREATE TABLE IF NOT EXISTS part (
83+
p_partkey BIGINT not null,
84+
p_name STRING not null,
85+
p_mfgr STRING not null,
86+
p_brand STRING not null,
87+
p_type STRING not null,
88+
p_size INTEGER not null,
89+
p_container STRING not null,
90+
p_retailprice DECIMAL(15, 2) not null,
91+
p_comment STRING not null
92+
) CLUSTER BY (p_partkey);
93+
SQL
94+
95+
cat <<SQL | bendsql query
96+
CREATE TABLE IF NOT EXISTS region (
97+
r_regionkey INTEGER not null,
98+
r_name STRING not null,
99+
r_comment STRING
100+
) CLUSTER BY (r_regionkey);
101+
SQL
102+
103+
cat <<SQL | bendsql query
104+
CREATE TABLE IF NOT EXISTS supplier (
105+
s_suppkey BIGINT not null,
106+
s_name STRING not null,
107+
s_address STRING not null,
108+
s_nationkey INTEGER not null,
109+
s_phone STRING not null,
110+
s_acctbal DECIMAL(15, 2) not null,
111+
s_comment STRING not null
112+
) CLUSTER BY (s_suppkey);
113+
SQL
114+
115+
for t in nation region; do
116+
echo "loading into $t ..."
117+
cat <<SQL | bendsql query
118+
COPY INTO $t FROM 's3://repo.databend.rs/tpch100/${t}.tbl'
119+
credentials=(aws_key_id='$REPO_ACCESS_KEY_ID' aws_secret_key='$REPO_SECRET_ACCESS_KEY')
120+
file_format=(type='CSV' field_delimiter='|' record_delimiter='\\n' skip_header=1);
121+
ANALYZE TABLE "${t}";
122+
SELECT count(*) as count_${t} FROM "${t}";
123+
SQL
124+
done
125+
126+
for t in customer lineitem orders partsupp part supplier; do
127+
echo "loading into $t ..."
128+
cat <<SQL | bendsql query
129+
COPY INTO $t FROM 's3://repo.databend.rs/tpch100/${t}/'
130+
credentials=(aws_key_id='$REPO_ACCESS_KEY_ID' aws_secret_key='$REPO_SECRET_ACCESS_KEY') pattern ='${t}.tbl.*'
131+
file_format=(type='CSV' field_delimiter='|' record_delimiter='\\n' skip_header=1);
132+
ANALYZE TABLE "${t}";
133+
SELECT count(*) as count_${t} FROM "${t}";
134+
SQL
135+
done

0 commit comments

Comments
 (0)