Skip to content

Commit d302bff

Browse files
committed
Load data into MySQL not into Minio
1 parent 5f6160c commit d302bff

File tree

5 files changed

+13
-101
lines changed

5 files changed

+13
-101
lines changed

data-image/Dockerfile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@ RUN mkdir -p /opt/data; \
4343
mkdir -p /opt/data/minio; \
4444
mkdir -p /opt/data/kafka;
4545

46-
# Copy Minio data files
47-
COPY ./data/*.tbl /opt/data/minio/
48-
49-
# Link Kafka data files
50-
RUN ln -s /opt/data/minio/lineitem.tbl /opt/data/kafka/lineitem.tbl; \
51-
ln -s /opt/data/minio/orders.tbl /opt/data/kafka/orders.tbl; \
52-
ln -s /opt/data/minio/rates.tbl /opt/data/kafka/rates.tbl;
53-
5446
# get mc and configure (minio client)
5547
RUN cd /opt; \
5648
wget https://dl.min.io/client/mc/release/linux-amd64/mc; \
File renamed without changes.

docker-compose.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ services:
2626
- MC_HOST_minio=http://sql-demo:demo-sql@minio:9000
2727
- KAFKA_HOST=kafka:9092
2828
- SPEEDUP=10.0
29+
volumes:
30+
- ./data:/opt/data/kafka
31+
# -./data:/opt/data/minio # all files located in /opt/data/minio are copied into Minio
2932
depends_on:
3033
- minio
3134
- kafka
@@ -58,6 +61,8 @@ services:
5861
build: ./metastore-image
5962
expose:
6063
- "9083"
64+
ports:
65+
- "9083:9083"
6166
minio:
6267
image: minio/minio:latest
6368
entrypoint: sh
@@ -89,12 +94,13 @@ services:
8994
- /var/run/docker.sock:/var/run/docker.sock
9095
mysql:
9196
image: mysql:8.0.19
92-
command: --default-authentication-plugin=mysql_native_password
97+
command: --default-authentication-plugin=mysql_native_password --secure_file_priv=/data
9398
environment:
9499
MYSQL_USER: "sql-demo"
95100
MYSQL_PASSWORD: "demo-sql"
96101
MYSQL_DATABASE: "sql-demo"
97102
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
98103
volumes:
99104
- ./mysql-init:/docker-entrypoint-initdb.d
105+
- ./data:/data
100106

flinksql-init/create_tables.sql

Lines changed: 1 addition & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
USE CATALOG hcat;
22

3-
CREATE TABLE dev_region (
4-
r_regionkey INTEGER,
5-
r_name STRING,
6-
r_comment STRING
7-
) WITH (
8-
'connector.type' = 'filesystem',
9-
'connector.path' = 's3://sql-demo/region.tbl',
10-
'format.type' = 'csv',
11-
'format.field-delimiter' = '|'
12-
);
13-
143
CREATE TABLE prod_region (
154
r_regionkey INTEGER,
165
r_name STRING,
@@ -26,18 +15,6 @@ CREATE TABLE prod_region (
2615
'connector.lookup.cache.ttl' = '0s'
2716
);
2817

29-
CREATE TABLE dev_nation (
30-
n_nationkey INTEGER,
31-
n_name STRING,
32-
n_regionkey INTEGER,
33-
n_comment STRING
34-
) WITH (
35-
'connector.type' = 'filesystem',
36-
'connector.path' = 's3://sql-demo/nation.tbl',
37-
'format.type' = 'csv',
38-
'format.field-delimiter' = '|'
39-
);
40-
4118
CREATE TABLE prod_nation (
4219
n_nationkey INTEGER,
4320
n_name STRING,
@@ -54,22 +31,6 @@ CREATE TABLE prod_nation (
5431
'connector.lookup.cache.ttl' = '0s'
5532
);
5633

57-
CREATE TABLE dev_customer (
58-
c_custkey INTEGER,
59-
c_name STRING,
60-
c_address STRING,
61-
c_nationkey INTEGER,
62-
c_phone STRING,
63-
c_acctbal DOUBLE,
64-
c_mktsegment STRING,
65-
c_comment STRING
66-
) WITH (
67-
'connector.type' = 'filesystem',
68-
'connector.path' = 's3://sql-demo/customer.tbl',
69-
'format.type' = 'csv',
70-
'format.field-delimiter' = '|'
71-
);
72-
7334
CREATE TABLE prod_customer (
7435
c_custkey INTEGER,
7536
c_name STRING,
@@ -90,17 +51,6 @@ CREATE TABLE prod_customer (
9051
'connector.lookup.cache.ttl' = '0s'
9152
);
9253

93-
CREATE TABLE dev_rates (
94-
rs_timestamp TIMESTAMP(3),
95-
rs_symbol STRING,
96-
rs_rate DOUBLE
97-
) WITH (
98-
'connector.type' = 'filesystem',
99-
'connector.path' = 's3://sql-demo/rates.tbl',
100-
'format.type' = 'csv',
101-
'format.field-delimiter' = '|'
102-
);
103-
10454
CREATE TABLE prod_rates (
10555
rs_timestamp TIMESTAMP(3),
10656
rs_symbol STRING,
@@ -116,45 +66,4 @@ CREATE TABLE prod_rates (
11666
'connector.lookup.cache.ttl' = '0s'
11767
);
11868

119-
CREATE TABLE dev_orders (
120-
o_orderkey INTEGER,
121-
o_custkey INTEGER,
122-
o_orderstatus STRING,
123-
o_totalprice DOUBLE,
124-
o_currency STRING,
125-
o_ordertime TIMESTAMP(3),
126-
o_orderpriority STRING,
127-
o_clerk STRING,
128-
o_shippriority INTEGER,
129-
o_comment STRING,
130-
WATERMARK FOR o_ordertime AS o_ordertime - INTERVAL '5' MINUTE
131-
) WITH (
132-
'connector.type' = 'filesystem',
133-
'connector.path' = 's3://sql-demo/orders.tbl',
134-
'format.type' = 'csv',
135-
'format.field-delimiter' = '|'
136-
);
137-
138-
CREATE TABLE dev_lineitem (
139-
l_orderkey INTEGER,
140-
l_partkey INTEGER,
141-
l_suppkey INTEGER,
142-
l_linenumber INTEGER,
143-
l_quantity DOUBLE,
144-
l_extendedprice DOUBLE,
145-
l_discount DOUBLE,
146-
l_tax DOUBLE,
147-
l_currency STRING,
148-
l_returnflag STRING,
149-
l_linestatus STRING,
150-
l_ordertime TIMESTAMP(3),
151-
l_shipinstruct STRING,
152-
l_shipmode STRING,
153-
l_comment STRING
154-
) WITH (
155-
'connector.type' = 'filesystem',
156-
'connector.path' = 's3://sql-demo/lineitem.tbl',
157-
'format.type' = 'csv',
158-
'format.field-delimiter' = '|'
159-
);
160-
69+
QUIT;

mysql-init/create_tables.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,8 @@ INSERT INTO PROD_RATES VALUES (TIMESTAMP '2020-04-19 10:01:52.154', 'CAD', 1.562
3838
INSERT INTO PROD_RATES VALUES (TIMESTAMP '2020-04-19 10:01:52.154', 'NOK', 10.9257);
3939
INSERT INTO PROD_RATES VALUES (TIMESTAMP '2020-04-19 10:01:52.154', 'RUB', 81.2930);
4040
INSERT INTO PROD_RATES VALUES (TIMESTAMP '2020-04-19 10:01:52.154', 'CNY', 8.0166);
41+
42+
LOAD DATA INFILE "/data/region.tbl" INTO TABLE PROD_REGION COLUMNS TERMINATED BY '|' LINES TERMINATED BY '\n';
43+
LOAD DATA INFILE "/data/nation.tbl" INTO TABLE PROD_NATION COLUMNS TERMINATED BY '|' LINES TERMINATED BY '\n';
44+
LOAD DATA INFILE "/data/customer.tbl" INTO TABLE PROD_CUSTOMER COLUMNS TERMINATED BY '|' LINES TERMINATED BY '\n';
45+
LOAD DATA INFILE "/data/rates.tbl" INTO TABLE PROD_RATES COLUMNS TERMINATED BY '|' LINES TERMINATED BY '\n';

0 commit comments

Comments
 (0)