本文介绍如何通过DLA向OSS中写入数据。
在DLA中创建OSS Schema。
CREATE SCHEMA oss_schema with DBPROPERTIES(
catalog='oss',
location = 'oss://mybucket/datasets/****/test/convert/'
);
在DLA中创建orders_txt表。
CREATE EXTERNAL TABLE orders_txt (
O_ORDERKEY INT,
O_CUSTKEY INT,
O_ORDERSTATUS STRING,
O_TOTALPRICE DOUBLE,
O_ORDERDATE DATE,
O_ORDERPRIORITY STRING,
O_CLERK STRING,
O_SHIPPRIORITY INT,
O_COMMENT STRING
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '|'
STORED AS TEXTFILE LOCATION 'oss://mybucket/datasets/****/test/convert/orders.tbl';
在DLA中创建orders_orc表。
CREATE EXTERNAL TABLE orders_orc (
O_ORDERKEY INT,
O_CUSTKEY INT,
O_ORDERSTATUS STRING,
O_TOTALPRICE DOUBLE,
O_ORDERDATE DATE,
O_ORDERPRIORITY STRING,
O_CLERK STRING,
O_SHIPPRIORITY INT,
O_COMMENT STRING
)
STORED AS ORC LOCATION 'oss://mybucket/datasets/****/test/convert/orders_orc/';
执行INSERT…SELECT,将orders_txt表中满足要求的数据插入orders_orc中。
INSERT INTO orders_orc SELECT * FROM orders_txt;