All Products
Search
Document Center

Hologres:Import data from a data lake to Hologres by executing SQL statements

Last Updated:Sep 05, 2024

This topic describes how to import data that is mapped to a Hologres foreign table in Object Storage Service (OSS) to a Hologres internal table for data queries.

Prerequisites

A data lake is created in DLF and the environment configuration is complete. You can use a Hologres external table to read data from OSS. For more information, see the Procedures section of the "Use DLF to read data from and write data to OSS" topic.

Import data to a Hologres internal table

You can import data from a foreign table to a Hologres internal table. This way, you can directly query the data with better user experience.

  1. Create an internal table in Hologres.

    The internal table that you want to create in Hologres must use the same schema as the foreign table. For more information about data types, see Data types. Sample statement:

    CREATE TABLE IF NOT EXISTS holo_dlf_oss_test(
     uuid int,
     name string,
     price double);
  2. Use a foreign table to import data from OSS to the Hologres internal table.

    Execute the INSERT INTO ... SELECT ... statement to synchronize data from the foreign table to the internal table. Sample statement:

    INSERT INTO holo_dlf_oss_test SELECT uuid,name,price FROM dlf_oss_test;
  3. Query data in the internal table.

    Execute the following statement to query data in the internal table:

    SELECT * FROM holo_dlf_oss_test;