This topic describes how to convert a text file to the RCFile format. The nation.tbl file is used as an example.

  1. Create an Object Storage Service (OSS) schema.

    ​CREATE SCHEMA dla_oss_db with DBPROPERTIES(
      catalog='oss',
      location 'oss://bucket-name/TPC-H/'
      )​
  2. Create the nation_txt table in the Data Lake Analytics (DLA) console and set the LOCATION parameter to the path of nation.tbl in an OSS bucket.

    ​CREATE EXTERNAL TABLE nation_txt(
         n_nationkey int,
         n_name string,
         n_id string,
         n_regionkey int,
         n_comment string
     )
     ROW FORMAT DELIMITED
         FIELDS TERMINATED BY '|'
     STORED AS TEXTFILE
     LOCATION 'oss://bucket-name/TPC-H/nation/nation.tbl'​
  3. Create a table named nation_RCFile in the DLA console and set the LOCATION parameter to the path where you want to store the RCFile file in the OSS bucket.

    Note: You must set the LOCATION parameter to a path that exists in the OSS bucket and the path must end with a forward slash (/).

    ​CREATE EXTERNAL TABLE nation_RCFile(
         n_nationkey int,
         n_name string,
         n_id string,
         n_regionkey int,
         n_comment string
     )
     ROW FORMAT DELIMITED
         FIELDS TERMINATED BY '|'
     STORED AS RCFile
     LOCATION 'oss://bucket-name/TPC-H/nation_RCFile/'​

    STORED AS RCFile: indicates that the file is stored in the RCFile format.

  4. Execute the INSERT...SELECT statement to insert data of the nation_txt table to the nation_RCFile table.

     INSERT INTO nation_RCFile SELECT * FROM nation_txt;
  5. View the data of the nation_RCFile table.

    After the INSERT...SELECT statement is executed, you can view the generated RCFile table in the OSS bucket.