You can create a Hologres external table by using DDL statements or the visual tools in DataWorks. This topic describes how to use the visual tools in DataWorks to create a Hologres external table.
Prerequisites
You have added a Hologres compute resource to your workspace and associated it with Data Studio. For more information, see Data Studio (legacy): Associate a Hologres computing resource.
You have the Workspace Administrator or Development role. For more information about how to grant roles, see Manage permissions on workspace-level services.
Background information
Hologres supports two types of tables: internal tables and external tables. They differ in the following ways:
An internal table stores data directly from MaxCompute. You can synchronize data from a MaxCompute source table to a Hologres internal table for fast queries and analysis. This method offers better query performance than using an external table.
An external table does not store data directly. Instead, it maps to a MaxCompute source table to accelerate data queries and analysis. This method avoids data redundancy and eliminates the need for data import and export, allowing you to get query results quickly.
DataWorks, as a data development platform, provides a convenient visual method for creating tables. To create multiple Hologres external tables at a time, you can use the Schema synchronization from MaxCompute feature. You can also create tables directly in Hologres by using DDL statements. For more information, see CREATE FOREIGN TABLE.
Limits
-
You can create only Hologres external tables that are mapped to MaxCompute tables.
-
This feature is available only in the China (Shanghai) and China (Beijing) regions.
Procedure
-
Go to the Data Studio page.
Log on to the DataWorks console. In the target region, click in the left-side navigation pane. Select a workspace from the drop-down list and click Go to Data Integration.
-
Create a Workflow.
If you have an existing Workflow, skip this step.
-
Hover over the
icon and select Create Workflow. -
In the Create Workflow dialog box, enter a Workflow Name.
-
Click Create.
-
-
Create a Hologres external table.
-
Hover over the
icon and choose . -
In the Create Table dialog box, select External Table for Table Type, and configure the engine, path, and name for the table.
After you complete the configuration, click Create.
-
-
Configure the Hologres external table.
On the configuration page for the Hologres external table, configure the properties of the table.
-
Configure basic properties.
The following table describes the main basic properties.
Parameter
Description
Type
The type of Hologres external table to create.
NoteYou can create only Hologres external tables that are mapped to MaxCompute tables.
Servers
The server that the external table uses to connect to the MaxCompute data source.
NoteTo create an external table for MaxCompute, you must call the
odps_serverexternal table server that is already created in the underlying layer of Hologres. For more information about the principle, see postgres_fdw.Table
The MaxCompute source table that the Hologres external table queries.
You must configure the following parameters based on the model type of the MaxCompute project:
-
two-layer model:
-
project_name: the name of the MaxCompute project.
-
table_name: the name of the MaxCompute source table to be queried.
-
-
three-layer model:
-
project_name: the name of the MaxCompute project and schema, in the format of
odps_project_name#odps_schema_name. -
table_name: the name of the MaxCompute source table to be queried.
-
NoteIf the configured parameters do not meet the requirements of the model type, an error is reported. Example:
failed to import foreign schema:Table not found - table_xxx. -
Configure business information.
NoteThe business information of a table is only used for management purposes based on business requirements and does not involve underlying logic implementation.
Parameter
Description
Theme
The level-1 folder and level-2 folder to which the table belongs. You can classify tables based on business purposes and place tables of the same type in the same folder.
NoteLevel-1 themes and level-2 themes are only the folder structure presented in DataWorks and are intended to help you manage tables.
Layer
The physical data warehouse layer to which the table belongs. Layers are used to define and manage the hierarchy of a data warehouse. Typical layers include the staging layer, the shared layer, and the analytics layer. You can assign the table to an appropriate layer based on its business purpose.
NoteClick the
icon to customize layers. For more information, see Table management.Physical Category
The physical category of the table. This provides a more detailed classification of the table from a business perspective. Typical categories include the basic business layer, the advanced business layer, and others.
NoteClick the
icon to customize physical categories. For more information, see Category management.-
Configure the table schema.
On the Table Structure Design page, go to the Field Design tab and select the fields to map to the Hologres external table. In this example, the two text-type fields
smischemaandsmitableare selected. After you configure the Table parameter under Configure basic properties in Step 4, the schema from the MaxCompute source table is automatically displayed. This schema is used to create the final Hologres external table and cannot be edited.NoteWhen you create a Hologres external table based on a MaxCompute table, data types are mapped between the two. The field types in the external table must correspond one-to-one with the field types in the MaxCompute source table. For information about data type mappings between MaxCompute and Hologres, see Data type mappings between MaxCompute and Hologres.
-
-
Commit and deploy the Hologres external table.
After you define the table structure, you must submit it to the development environment and the production environment. The table is visible in the corresponding engine project only after it is successfully submitted.
NoteIf your workspace is in basic mode, you only need to submit the table to the production environment. For more information about basic mode and standard mode workspaces, see Workspace mode differences.
Operation
Description
Load from Development Environment
Loads information about the development table from the development environment and displays it on the current page.
NoteThis operation is available only after the table has been submitted to the development environment. After this operation is performed, the table information from the development environment overwrites the table information on the current page.
Commit to Development Environment
Submits the table to the development environment of DataWorks, which creates the table in the Hologres database that corresponds to the development environment.
After you submit the table, you can view the table structure in the Hologres directory of the corresponding workflow (the path you selected when creating the table) in Data Studio.
Load from Production Environment
Loads information about the production table from the production environment and displays it on the current page.
NoteThis operation is available only after the table has been submitted to the production environment. After this operation is performed, the table information from the production environment overwrites the table information on the current page.
Commit to Production Environment
Submits the table to the production environment of DataWorks, which creates the table in the Hologres database that corresponds to the production environment.
Next steps
After the Hologres external table is created, you can use it to periodically import data from MaxCompute to a Hologres internal table. You can use one of the following methods to import data:
-
Import data by using SQL commands. For more information, see Import data from MaxCompute by using SQL.
-
Import data by using the visual tools in DataWorks. For more information, see Data synchronization from MaxCompute node.