@@ -7,118 +7,118 @@ select version();
77SQL
88
99for t in customer lineitem nation orders partsupp part region supplier; do
10- echo " DROP TABLE IF EXISTS $t ;" | bendsql query
10+ echo " DROP TABLE IF EXISTS $t ;" | bendsql query
1111done
1212
1313cat << SQL | bendsql query
1414 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- );
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) ;
2424SQL
2525
2626cat << SQL | bendsql query
2727 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,
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,
4040 l_receiptdate DATE not null,
4141 l_shipinstruct STRING not null,
42- l_shipmode STRING not null,
43- l_comment STRING not null
44- );
42+ l_shipmode STRING not null,
43+ l_comment STRING not null
44+ ) CLUSTER BY(l_shipdate, l_orderkey) ;
4545SQL
4646
4747# create tpch tables
4848cat << SQL | bendsql query
4949 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- );
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) ;
5555SQL
5656
5757cat << SQL | bendsql query
5858 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- );
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) ;
6969SQL
7070
7171cat << SQL | bendsql query
7272 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- );
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) ;
7979SQL
8080
8181cat << SQL | bendsql query
8282 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,
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,
9090 p_retailprice DECIMAL(15, 2) not null,
91- p_comment STRING not null
92- );
91+ p_comment STRING not null
92+ ) CLUSTER BY (p_partkey) ;
9393SQL
9494
9595cat << SQL | bendsql query
9696 CREATE TABLE IF NOT EXISTS region (
97- r_regionkey INTEGER not null,
98- r_name STRING not null,
99- r_comment STRING
100- );
97+ r_regionkey INTEGER not null,
98+ r_name STRING not null,
99+ r_comment STRING
100+ ) CLUSTER BY (r_regionkey) ;
101101SQL
102102
103103cat << SQL | bendsql query
104104 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- );
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) ;
113113SQL
114114
115115for t in customer lineitem nation orders partsupp part region supplier; do
116- echo " loading into $t ..."
117- cat << SQL | bendsql query
118- COPY INTO $t FROM 's3://repo.databend.rs/tpch10/${t} /'
119- credentials=(aws_key_id='$AWS_KEY_ID ' aws_secret_key='$AWS_SECRET_KEY ') pattern ='${t} .*'
116+ echo " loading into $t ..."
117+ cat << SQL | bendsql query
118+ COPY INTO $t FROM 's3://repo.databend.rs/datasets/ tpch10/${t} /'
119+ credentials=(aws_key_id='$REPO_ACCESS_KEY_ID ' aws_secret_key='$REPO_SECRET_ACCESS_KEY ') pattern ='${t} .*'
120120file_format=(type='CSV' field_delimiter='|' record_delimiter='\\ n' skip_header=0);
121- ANALYZE TABLE ' ${t} ' ;
122- SELECT count(*) as count_${t} FROM ' ${t} ' ;
121+ ANALYZE TABLE " ${t} " ;
122+ SELECT count(*) as count_${t} FROM " ${t} " ;
123123SQL
124124done
0 commit comments