Use Flink SQL to connect to a Data Lake Formation (DLF) catalog through the Iceberg REST protocol, then query Iceberg tables directly from your Flink session cluster.
Prerequisites
Before you begin, ensure that you have:
-
A Realtime Compute for Apache Flink workspace. See Activate Realtime Compute for Apache Flink.
-
A session cluster running Ververica Runtime (VVR) 11.2.0 or later. See Create a session cluster.
Register the DLF catalog in Flink
Registering a catalog in Flink creates a mapping to your DLF catalog. Creating or deleting the catalog in Flink does not affect the actual data in DLF. All tables created in the DLF catalog through Iceberg REST are Iceberg tables.
-
Log on to the Realtime Compute for Apache Flink Management Console.
-
In the Actions column of your workspace, click Console.
-
In the left navigation pane, click Development > Scripts.
-
Create a new script, then paste the following SQL statement into the SQL editor.
CREATE CATALOG `catalog_name` WITH ( 'type' = 'iceberg', 'catalog-type' = 'rest', 'uri' = 'http://{region-id}-vpc.dlf.aliyuncs.com/iceberg', 'warehouse' = 'iceberg_test', 'rest.signing-region' = '{region-id}', 'io-impl' = 'org.apache.iceberg.rest.DlfFileIO' );Replace
{region-id}with the region ID of your DLF catalog, for examplecn-hangzhouorap-southeast-1. For all supported regions and their endpoint values, see Regions and endpoints. -
In the lower-right corner, click Environment, select a session cluster running VVR 11.2.0 or later, and run the SQL statement.
The following table describes the configuration options.
| Option | Description | Required | Example |
|---|---|---|---|
type |
The catalog type. Set to iceberg. |
Yes | iceberg |
catalog-type |
The catalog type. Set to rest. |
Yes | rest |
token.provider |
The token provider for DLF authentication. Set to dlf. |
Yes | dlf |
uri |
The Iceberg REST endpoint for your DLF catalog. Use the format http://{region-id}-vpc.dlf.aliyuncs.com/iceberg. For region-specific values, see Regions and endpoints. |
Yes | http://ap-southeast-1-vpc.dlf.aliyuncs.com/iceberg |
warehouse |
The name of your DLF catalog. | Yes | iceberg_test |
rest.signing-region |
The region ID of your DLF catalog. For region IDs, see Regions and endpoints. | Yes | ap-southeast-1 |
io-impl |
The FileIO implementation for DLF. Set to org.apache.iceberg.rest.DlfFileIO. |
Yes | org.apache.iceberg.rest.DlfFileIO |
Query data in the catalog
After registering the catalog, run the following SQL statement in Scripts:
SELECT * FROM catalog_name.database_name.table_name;
Replace catalog_name, database_name, and table_name with the actual names from your DLF catalog.