Hologres V3.2 and later support accessing Data Lake Formation (DLF) Catalog data through Paimon REST. Once connected, you can query Paimon tables directly from Hologres, use time travel to inspect historical snapshots, read from specific branches, and load data incrementally into dynamic tables.
Prerequisites
Before you begin, ensure that you have:
-
An active DLF service with at least one catalog. See Grant permissions and activate DLF and Data Catalog
-
A Hologres instance with the data lake acceleration service enabled. The instance must be in the same region as DLF. See Environment configuration
Limitations
-
Writing to Paimon tables is not supported. INSERT, UPDATE, DELETE, and TRUNCATE operations are unavailable.
-
Time travel queries, branch queries, and data mirroring are only available for Paimon tables mapped through an external database — not through a foreign server.
-
Time travel is not supported on tables that have undergone schema evolution, or on dynamic tables.
-
Data mirroring does not support Paimon tables with primary keys.
-
Reading from default partitions where the partition key is NULL or empty is not supported.
-
The OSS data lake acceleration feature in HoloWeb cannot visually create a DLF Catalog.
-
The data lake acceleration feature cannot be enabled for read-only secondary instances.
Choose an auth mode
Hologres supports two modes for authenticating access to a DLF Catalog:
| Mode | When to use |
|---|---|
| SLR (service-linked role) | Default. Use when accessing data under your current Alibaba Cloud identity. Hologres handles cross-service authorization automatically through identity pass-through. |
| STS (Security Token Service) | Use for cross-account access, or when a Hologres BASIC account needs access to DLF. Requires a RAM role and explicit user mapping. |
Start with SLR mode unless cross-account access or BASIC account support is required.
Map a catalog using an external database
SLR mode
A service-linked role (SLR) is a RAM role that authorizes an Alibaba Cloud service to access other services on your behalf. Hologres creates and manages the SLR automatically — no manual role setup is needed. See Service-linked role.
-
Connect to a Hologres instance and create an external database.
Parameter Required Description catalog_typeYes Always paimonfor Paimon tables.metastore_typeYes Always dlf-restwhen connecting through DLF.dlf_catalogYes The name of your DLF Catalog. commentNo A description for the external database. CREATE EXTERNAL DATABASE <ext_database_name> WITH catalog_type 'paimon' metastore_type 'dlf-rest' dlf_catalog '<dlf_catalog_name>' comment 'Catalog on dlf' ; -
View the schemas and tables in the external database.
-- List schemas in the external database SELECT * FROM hologres.hg_external_schemas('<ext_database_name>'); -- List tables in a specific schema SELECT * FROM hologres.hg_external_tables('<ext_database_name>', '<ext_schema_name>'); -
Query data.
SELECT * FROM <ext_database_name>.<ext_schema_name>.<ext_table_name>;
STS mode
Security Token Service (STS) issues temporary credentials with configurable permissions and validity periods. Use this mode when a RAM user or BASIC account from a different account needs to access DLF data through Hologres.
-
In the RAM console, create a RAM role and attach either the AliyunDLFFullAccess or AliyunDLFReadOnlyAccess permission. See Create a RAM role and grant permissions.
-
Edit the RAM role's trust policy to allow Hologres to assume it. See Modify the trust policy of a RAM role.
{ "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "Service": [ "hologres.aliyuncs.com" ] } } ], "Version": "1" } -
In the Data Lake Formation console, grant the RAM role access to the relevant databases and tables. See Permission management.
-
In Hologres, create an external database and reference the RAM role.
Parameter Required Description catalog_typeYes Always paimonfor Paimon tables.metastore_typeYes Always dlf-restwhen connecting through DLF.dlf_catalogYes The name of your DLF Catalog. rolearnYes The Alibaba Cloud Resource Name (ARN) of the RAM role created in step 1. Format: acs:ram::<account-id>:role/<role-name>.commentNo A description for the external database. CREATE EXTERNAL DATABASE <ext_database_name> WITH catalog_type 'paimon' metastore_type 'dlf-rest' dlf_catalog '<dlf_catalog_name>' rolearn 'acs:ram::106380604****:role/***-ramrole' comment 'Catalog on dlf' ; -
Create a user mapping to bind the RAM user or BASIC account to the RAM role.
For details on user mappings, see CREATE USER MAPPING. To create a RAM user, see Create a RAM user. To create a BASIC account, see User management.
CREATE USER MAPPING FOR "<RAM_user|BASIC_account>" EXTERNAL DATABASE <ext_database_name> OPTIONS ( rolearn 'acs:ram::10638060***:role/***ramrole' ); -
Log in as the RAM user through the Hologres Management Console, or connect using the BASIC account, then query data.
SELECT * FROM <ext_database_name>.<ext_schema_name>.<ext_table_name>;
Accelerate queries using lake table mirroring
Hologres V3.2 and later support lake table mirroring, which syncs metadata and data from an external data source into Hologres — either in near real time or at scheduled intervals. Mirroring supports full tables and specific partitions of partitioned tables. See Lake table mirroring.
External schema operations
Create an external schema
Creating an external schema creates a corresponding database in the DLF Catalog.
CREATE EXTERNAL SCHEMA [IF NOT EXISTS] <ext_database_name>.<ext_schema_name>;
Refresh schema metadata
REFRESH CACHE FOR EXTERNAL SCHEMA <ext_database_name>.<ext_schema_name> WITH (cache_level = 'metadata');
Delete an external schema
Deleting an external schema removes the corresponding database and all its tables from the DLF Catalog. This operation cannot be undone.
DROP EXTERNAL SCHEMA [IF NOT EXISTS] <ext_database_name>.<ext_schema_name>;
List tables in a schema
SELECT * FROM hologres.hg_external_tables('<ext_database_name>', '<ext_schema_name>');
External table operations
Create an external table
-- Non-partitioned table
CREATE EXTERNAL TABLE <ext_database_name>.<ext_schema_name>.<ext_table_name>(
id TEXT,
created_at BIGINT,
type TEXT,
actor_id TEXT,
actor_login TEXT,
repo_id TEXT,
repo_name TEXT,
org TEXT,
org_login TEXT,
PRIMARY KEY(id)
) WITH (
"changelog-producer"='input',
"bucket"=6,
"bucket-key"='id'
);
-- Partitioned table
CREATE EXTERNAL TABLE <ext_database_name>.<ext_schema_name>.<ext_table_name>(
id TEXT,
created_at BIGINT,
type TEXT,
actor_id TEXT,
actor_login TEXT,
repo_id TEXT,
repo_name TEXT,
org TEXT,
org_login TEXT
)
LOGICAL PARTITION BY LIST(created_at)
WITH (
"file_format" = 'orc',
"bucket"=6,
"bucket-key"='id'
);
Refresh table metadata
REFRESH CACHE FOR EXTERNAL TABLE <ext_db_name>.<ext_schema_name>.<ext_table_name> WITH (cache_level = 'metadata');
Delete an external table
Deleting an external table removes the table from the DLF Catalog. This operation cannot be undone.
DROP EXTERNAL TABLE IF EXISTS <ext_database_name>.<ext_schema_name>.<ext_table_name>;
Collect table statistics
ANALYZE and AUTO ANALYZE collect column statistics that the query optimizer uses to generate efficient query plans. See ANALYZE and AUTO ANALYZE.
-- Collect statistics for all columns
ANALYZE <ext_database_name>.<ext_schema_name>.<ext_table_name>;
-- Collect statistics for specific columns (higher sample rate — use for columns with conditional filters)
ANALYZE <ext_database_name>.<ext_schema_name>.<ext_table_name>(<colname>, <colname>);
-- Enable auto-analyze for the external database
ALTER EXTERNAL DATABASE <ext_database_name> WITH enable_auto_analyze 'true';
Time travel queries
Hologres V3.2 and later support querying historical snapshots of Paimon tables. All three approaches use the FOR ... AS OF syntax:
-- Query by timestamp
SELECT * FROM '<ext_database_name>.<ext_schema_name>.<ext_table_name>' FOR TIMESTAMP AS OF '<timestamp>';
-- Query by version (version = snapshot ID for Paimon tables)
SELECT * FROM '<ext_database_name>.<ext_schema_name>.<ext_table_name>' FOR VERSION AS OF '<version>';
-- Query by tag
SELECT * FROM '<ext_database_name>.<ext_schema_name>.<ext_table_name>' FOR TAG AS OF '<tag>';
To find available snapshots or tags, query the Paimon system tables first.
Query the Snapshots system table
SELECT * FROM hologres.hg_list_snapshots('<ext_database_name>.<ext_schema_name>.<ext_table_name>');
The result maps to the Paimon Snapshots system table as follows:
| Field | Type | Description | Paimon field |
|---|---|---|---|
branch_name |
TEXT | Branch name | branch_name |
snapshot_id |
TEXT | Snapshot ID | snapshot_id |
schema_id |
TEXT | Table schema ID | schema_id |
commit_kind |
TEXT | Commit type | commit_kind |
commit_time |
TIMESTAMPTZ | Commit time | commit_time |
extend_info |
TEXT (JSON) | Other Paimon snapshot properties | — |
To list available snapshot IDs, use hg_list_versions:
SELECT * FROM hologres.hg_list_versions('<ext_database_name>.<ext_schema_name>.<ext_table_name>');
Query the Tags system table
SELECT * FROM hologres.hg_list_tags('<ext_database_name>.<ext_schema_name>.<ext_table_name>');
| Field | Type | Description | Paimon field |
|---|---|---|---|
branch_name |
TEXT | Branch name | branch_name |
tag_name |
TEXT | Tag name | tag_name |
snapshot_id |
TEXT | Snapshot ID | snapshot_id |
schema_id |
TEXT | Table schema ID | schema_id |
commit_time |
TIMESTAMPTZ | Commit time | commit_time |
extend_info |
TEXT (JSON) | Other Paimon tag properties | — |
Branch queries
Hologres V3.2 and later support querying data from a specific branch in a Paimon table.
List branches
SELECT * FROM hologres.hg_list_branches('<ext_database_name>.<ext_schema_name>.<ext_table_name>');
| Field | Type | Description | Paimon field |
|---|---|---|---|
branch_name |
TEXT | Branch name | branch_name |
create_time |
TIMESTAMPTZ | Branch creation time | create_time |
extend_info |
TEXT (JSON) | Other Paimon branch properties | — |
Query data from a branch
-- Query the current state of a branch
SELECT * FROM '<ext_database_name>.<ext_schema_name>.<ext_table_name>' FOR branch AS OF '<branch_name>';
-- Query a historical snapshot of a branch by timestamp
SELECT * FROM '<ext_database_name>.<ext_schema_name>.<ext_table_name>' FOR branch AS OF '<branch_name>' TIMESTAMP AS OF '<timestamp>';
-- Query a historical snapshot of a branch by tag
SELECT * FROM '<ext_database_name>.<ext_schema_name>.<ext_table_name>' FOR branch AS OF '<branch_name>' TAG AS OF '<tag_name>';
If the scan.fallback-branch property is set on a Paimon table and a partition is missing from the current branch, Hologres automatically reads that partition from the fallback branch. See Manage Branch for details.
Access Paimon tables through a foreign server
As an alternative to external databases, you can use a foreign server and foreign tables to access Paimon data. This approach uses the standard PostgreSQL foreign data wrapper (FDW) interface.
Time travel queries, branch queries, and data mirroring are not available through foreign tables. Use external databases for those features.
-
Create a foreign server.
CREATE SERVER IF NOT EXISTS <server_name> FOREIGN DATA WRAPPER dlf_fdw OPTIONS ( catalog_type 'paimon', metastore_type 'dlf-rest', dlf_catalog '<dlf_catalog_name>' );For additional server options, see More operations on foreign servers (SQL).
-
Create foreign tables using one of the following methods. Option 1: Import an entire schema at once
IMPORT FOREIGN SCHEMA <dlf_db_name> FROM SERVER <server_name> INTO <holo_schema_name> OPTIONS (if_table_exist 'update');See IMPORT FOREIGN SCHEMA. Option 2: Create individual tables
CREATE FOREIGN TABLE <foreign_table_name> ( { column_name data_type } [, ... ] ) SERVER <server_name> OPTIONS ( schema_name '<dlf_db_name>', table_name '<dlf_table_name>' );See CREATE FOREIGN TABLE.
Read Paimon data using dynamic tables
A dynamic table automatically refreshes its contents from one or more base tables on a configurable schedule. Hologres V3.0 and later support MaxCompute foreign tables and DLF foreign tables as base tables for dynamic tables. See Dynamic table.
All three refresh modes use the same CREATE DYNAMIC TABLE structure. The auto_refresh_mode parameter controls how data is read from the Paimon source.
-- Full refresh: re-reads all data on each cycle
CREATE DYNAMIC TABLE paimon_dt_full
WITH (
auto_refresh_mode = 'full',
freshness = '3 minutes'
) AS SELECT * FROM <ext_database_name>.<ext_schema_name>.<ext_table_name>;
-- Incremental refresh: reads only new or changed data
CREATE DYNAMIC TABLE paimon_dt_incremental
WITH (
auto_refresh_mode = 'incremental',
freshness = '3 minutes'
) AS SELECT * FROM <ext_database_name>.<ext_schema_name>.<ext_table_name>;
-- Auto mode: Hologres selects full or incremental refresh based on data characteristics
CREATE DYNAMIC TABLE paimon_dt_auto
WITH (
auto_refresh_mode = 'auto',
freshness = '3 minutes'
) AS SELECT * FROM <ext_database_name>.<ext_schema_name>.<ext_table_name>;