Updated on 2025-09-19 GMT+08:00

Importing Data

Creating a LakeFormation Data Source

Create a LakeFormation data source. For details, see section "Managing LakeFormation Data Sources" in Data Warehouse Service (DWS) User Guide.

Creating an External Schema

Create an external schema. Set Server Name to the name of the created LakeFormation data source, DATABASE to the LakeFormation database to be accessed, Source to lakeformation, and Catalog to the catalog of the LakeFormation database to be accessed.
1
2
3
4
5
6
DROP SCHEMA IF EXISTS ex1;  
CREATE EXTERNAL SCHEMA ex1     
    WITH SOURCE lakeformation          
         DATABASE 'default'          
         SERVER lf_server          
         catalog 'hive';

Role Authorization

  1. Query the current user.
    1
    select current_user; 
    
  2. Create a role with the same name and grant permissions to the role.

    For details, see section "Role Authorization" in the LakeFormation Usage Guide.

Importing Data

  1. Create a local table for data import.
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    DROP TABLE IF EXISTS product_info;
    CREATE TABLE product_info
    (
        _hoodie_commit_time text,
        _hoodie_commit_seqno text,
        _hoodie_record_key text,
        _hoodie_partition_path text,
        _hoodie_file_name text,
        product_price                integer        ,
        product_id                   char(30)       ,
        product_time                 date           ,
        product_level                char(10)       ,
        product_name                 varchar(200)   ,
        product_type1                varchar(20)    ,
        product_type2                char(10)       ,
        product_monthly_sales_cnt    integer        ,
        product_comment_time         date           ,
        product_comment_num          integer        ,
        product_comment_content      varchar(200)                   
    ) ;
    
  2. Import the target table from the Hive table.
    1
    INSERT INTO product_info SELECT * FROM ex1.product_info_orc; 
    
  3. Query the import result.
    1
    SELECT * FROM product_info;