This topic describes how to connect to a Data Lake Formation (DLF) catalog from your Realtime Compute for Apache Flink workspace using Flink SQL and Paimon REST.
Prerequisites
-
You have a fully managed workspace for Realtime Compute for Apache Flink. If you have not created one, see Activate Realtime Compute for Apache Flink.
-
Ensure that your Realtime Compute for Apache Flink workspace and DLF are in the same region. You must also add the workspace's VPC to the DLF whitelist. For more information, see Configure a VPC whitelist.
Limitations
Only Ververica Runtime (VVR) 11.1.0 or later supports connecting to a DLF catalog.
Create a DLF catalog
For more information, see Get started with DLF .
Register the catalog in Flink
This operation maps your DLF catalog as metadata only. Creating or deleting this catalog in Realtime Compute for Apache Flink does not affect the underlying data in DLF.
-
Log on to the Realtime Compute console.
-
In the list of fully managed workspaces, click the name of your workspace to open its console.
-
You can register the catalog by using the UI or by running SQL commands.
UI
-
In the navigation pane on the left, click Catalogs.
-
On the Catalog List page, click Create Catalog.
-
Select Apache Paimon and click Next.
-
Set metastore to dlf. For catalog name, select the desired DLF catalog. Click OK to create the catalog.
SQL commands
In the Scripts editor, enter and run the following SQL statement to create the catalog.
CREATE CATALOG `flink_catalog_name` WITH ( 'type' = 'paimon', 'metastore' = 'rest', 'token.provider' = 'dlf', 'uri' = 'http://cn-hangzhou-vpc.dlf.aliyuncs.com', 'warehouse' = 'dlf_test' );The following table describes the parameters.
Parameter
Description
Required
Example
type
The type of the catalog. This parameter is fixed to
paimon.Yes
paimon
metastore
The type of the metastore. This parameter is fixed to
rest.Yes
rest
token.provider
The token provider. This parameter is fixed to
dlf.Yes
dlf
uri
The URI for accessing the DLF REST Catalog Server. The format is
http://[region-id]-vpc.dlf.aliyuncs.com. For more information about region IDs, see Endpoints.Yes
http://cn-hangzhou-vpc.dlf.aliyuncs.com
warehouse
The name of the underlying DLF catalog to use as the warehouse.
Yes
dlf_test
-
Common errors
java.lang.NullPointerException
-
Example stack trace:
Caused by: java.lang.NullPointerException at org.apache.paimon.rest.HttpClient.getRequestUrl(HttpClient.java:180) at org.apache.paimon.rest.HttpClient.get(HttpClient.java:108) at org.apache.paimon.rest.RESTCatalog.<init>(RESTCatalog.java:159) at org.apache.paimon.rest.RESTCatalog.<init>(RESTCatalog.java:141) at org.apache.paimon.rest.RESTCatalogFactory.create(RESTCatalogFactory.java:36) at org.apache.paimon.catalog.CatalogFactory.createUnwrappedCatalog(CatalogFactory.java:84) at org.apache.paimon.catalog.CatalogFactory.createCatalog(CatalogFactory.java:71) at org.apache.paimon.flink.VvrCatalogFactory.createCatalog(VvrCatalogFactory.java:67) at org.apache.paimon.flink.VvrCatalogFactory.createCatalog(VvrCatalogFactory.java:37) at org.apache.flink.table.gateway.vvr.module.delegation.CatalogFactoryWrapper.createCatalog(CatalogFactoryWrapper.java:91) at org.apache.flink.table.factories.FactoryUtil.createCatalog(FactoryUtil.java:572) ... 23 more -
Solution:
Check the value of the uri parameter in your catalog configuration. The value must start with
http://.
ForbiddenException: You are not authorized to do this operation
-
Example stack trace:
Caused by: org.apache.paimon.rest.exceptions.ForbiddenException: Forbidden: You are not authorized to do this operation. Action: dlf:GetConfig. AccessDeniedDetail : {"AuthAction":"dlf:GetConfig","AuthPrincipalType":"AssumedRoleUser","AuthPrincipalOwnerId":"xxxxx","AuthPrincipalDisplayName":"aliyunstreamasidefaultrole:xxxxx","PolicyType":"AccountLevelIdentityBasedPolicy","NoPermissionType":"ImplicitDeny"} requestId:xxxxx at org.apache.paimon.rest.DefaultErrorHandler.accept(DefaultErrorHandler.java:59) at org.apache.paimon.rest.DefaultErrorHandler.accept(DefaultErrorHandler.java:35) at org.apache.paimon.rest.HttpClient.exec(HttpClient.java:205) at org.apache.paimon.rest.HttpClient.get(HttpClient.java:112) at org.apache.paimon.rest.RESTCatalog.<init>(RESTCatalog.java:159) at org.apache.paimon.rest.RESTCatalog.<init>(RESTCatalog.java:141) at org.apache.paimon.rest.RESTCatalogFactory.create(RESTCatalogFactory.java:36 -
Solution:
Grant the AliyunDLFFullAccess policy to the AliyunStreamAsiDefaultRole role. This step may become unnecessary with future product updates.
-
Log on to the RAM console with your Alibaba Cloud account or as a RAM administrator.
-
In the navigation pane on the left, navigate to and find the AliyunStreamAsiDefaultRole role.
-
In the Actions column, click Grant Permission.
-
In the Policy section, search for and select the AliyunDLFFullAccess policy. Click Grant Permissions.
-