全部产品
Search
文档中心

云原生数据湖分析 DLA - 文档停止维护:数据写入OSS

更新时间:May 06, 2019

本文介绍如何通过DLA向OSS中写入数据。

  1. 在DLA中创建OSS Schema。

    1. CREATE SCHEMA oss_schema with DBPROPERTIES(
    2. catalog='oss',
    3. location = 'oss://mybucket/datasets/****/test/convert/'
    4. );
  2. 在DLA中创建orders_txt表。

    1. CREATE EXTERNAL TABLE orders_txt (
    2. O_ORDERKEY INT,
    3. O_CUSTKEY INT,
    4. O_ORDERSTATUS STRING,
    5. O_TOTALPRICE DOUBLE,
    6. O_ORDERDATE DATE,
    7. O_ORDERPRIORITY STRING,
    8. O_CLERK STRING,
    9. O_SHIPPRIORITY INT,
    10. O_COMMENT STRING
    11. )
    12. ROW FORMAT DELIMITED FIELDS TERMINATED BY '|'
    13. STORED AS TEXTFILE LOCATION 'oss://mybucket/datasets/****/test/convert/orders.tbl';
  3. 在DLA中创建orders_orc表。

    1. CREATE EXTERNAL TABLE orders_orc (
    2. O_ORDERKEY INT,
    3. O_CUSTKEY INT,
    4. O_ORDERSTATUS STRING,
    5. O_TOTALPRICE DOUBLE,
    6. O_ORDERDATE DATE,
    7. O_ORDERPRIORITY STRING,
    8. O_CLERK STRING,
    9. O_SHIPPRIORITY INT,
    10. O_COMMENT STRING
    11. )
    12. STORED AS ORC LOCATION 'oss://mybucket/datasets/****/test/convert/orders_orc/';
  4. 执行INSERT…SELECT,将orders_txt表中满足要求的数据插入orders_orc中。

    1. INSERT INTO orders_orc SELECT * FROM orders_txt;