跳转至

Connect Foundry's Iceberg catalog to Snowflake(将 Foundry 的 Iceberg 目录连接到 Snowflake)

Foundry can integrate with Snowflake through the Snowflake connector.

Snowflake can integrate with Foundry-managed Iceberg tables through an Apache Iceberg REST catalog integration ↗. If you encounter issues with these instructions, follow the authentication troubleshooting instructions.

:::callout{theme="warning" title="Limitations"} Currently, Snowflake only supports reading Foundry-managed Iceberg tables with bring-your-own-bucket storage.

Snowflake does not currently support reading tables with client-side encryption. :::

1. Create a catalog integration

  1. Enable your Snowflake instance to egress to your Foundry instance and to the Iceberg storage bucket.
  2. Configure network ingress in Foundry to allow your Snowflake instance to connect to Foundry.
  3. Run the following query in Snowflake to create a catalog integration ↗. You need to use the ACCOUNTADMIN role ↗ to run the query. See the Snowflake documentation ↗ for more details.

The following example uses OAuth2 authentication:

CREATE CATALOG INTEGRATION <name_your_integration>
  CATALOG_SOURCE = ICEBERG_REST
  TABLE_FORMAT = ICEBERG
  ENABLED = TRUE
  CATALOG_NAMESPACE = '<your_foundry_namespace>' -- Foundry folder, for example 'FoundryNamespace.MyProject.tables' for /FoundryNamespace/MyProject/tables
  REST_CONFIG = (
    CATALOG_NAME = 'foundry'
    CATALOG_URI = 'https://<your_foundry>/iceberg'
    CATALOG_API_TYPE = 'public'
    ACCESS_DELEGATION_MODE = VENDED_CREDENTIALS
  )

  REST_AUTHENTICATION = (
    TYPE = OAUTH
    OAUTH_TOKEN_URI = 'https://<your_foundry>/iceberg/v1/oauth/tokens'
    OAUTH_CLIENT_ID = '<client_id>'
    OAUTH_CLIENT_SECRET = '<client_secret>'
    OAUTH_ALLOWED_SCOPES = ( 'api:iceberg-read', 'api:iceberg-write' )
  );

2. Verify the integration

  1. Verify that the integration is configured correctly by running the following query. See Snowflake documentation ↗ for more details.
SELECT SYSTEM$VERIFY_CATALOG_INTEGRATION('<your_integration_name>');
  1. Verify that you can list namespaces ↗ and list Iceberg tables ↗ from the Foundry Iceberg REST catalog.
SELECT SYSTEM$LIST_NAMESPACES_FROM_CATALOG(
     '<your_integration_name>',
     '<your_foundry_folder>', -- Foundry folder, for example 'FoundryNamespace.MyProject.tables' for /FoundryNamespace/MyProject/tables
     1
 );
SELECT SYSTEM$LIST_ICEBERG_TABLES_FROM_CATALOG(
     '<your_integration_name>',
     '<your_foundry_folder>', -- Foundry folder, for example 'FoundryNamespace.MyProject.tables' for /FoundryNamespace/MyProject/tables
     1
 );

3. Register and read a table

Create a table that links to a Foundry table and verify that you can read data from it. This only reads data from Foundry, and does not overwrite or delete the table.

CREATE OR REPLACE ICEBERG TABLE <database>.<schema>.<name_your_table_in_snowflake>
    CATALOG = '<your_integration_name>'
    CATALOG_TABLE_NAME = '<table_rid>' -- or '<table_name_in_foundry>'
    CATALOG_NAMESPACE = 'foundry'  -- or '<table_namespace_in_foundry>' for example 'FoundryNamespace.MyProject.tables' for /FoundryNamespace/MyProject/tables
    AUTO_REFRESH = TRUE;

SELECT * FROM <database>.<schema>.<name_your_table_in_snowflake>;

4. Optionally write to a table

Write data to a Foundry Iceberg table in Snowflake.

INSERT INTO <database>.<schema>.<name_your_table_in_snowflake> VALUES
    <value_1>,
    <value_2>,
    <value_3>;
  1. Create a new database linked to the catalog integration:
CREATE DATABASE <name_your_integration_database>
  LINKED_CATALOG = (
    CATALOG = '<your_integration_name>'
  );
  1. Verify the catalog link status. See the Snowflake documentation ↗ for more details.
SELECT SYSTEM$CATALOG_LINK_STATUS('<name_your_integration_database>');

中文翻译

将 Foundry 的 Iceberg 目录连接到 Snowflake

Foundry 可以通过 Snowflake 连接器 与 Snowflake 集成。

Snowflake 可以通过 Apache Iceberg REST 目录集成 ↗ 与 Foundry 管理的 Iceberg 表集成。如果按照本说明操作时遇到问题,请参考身份验证故障排除说明

:::callout{theme="warning" title="限制"} 目前,Snowflake 仅支持读取使用自带存储桶存储的 Foundry 管理 Iceberg 表。

Snowflake 目前不支持读取启用了客户端加密的表。 :::

1. 创建目录集成

  1. 启用 Snowflake 实例,使其能够出站连接到您的 Foundry 实例以及 Iceberg 存储桶
  2. 在 Foundry 中配置网络入站规则,允许您的 Snowflake 实例连接到 Foundry。
  3. 在 Snowflake 中运行以下查询以创建目录集成 ↗。您需要使用 ACCOUNTADMIN 角色 ↗ 来运行该查询。更多详情请参阅 Snowflake 文档 ↗

以下示例使用 OAuth2 身份验证

CREATE CATALOG INTEGRATION <name_your_integration>
  CATALOG_SOURCE = ICEBERG_REST
  TABLE_FORMAT = ICEBERG
  ENABLED = TRUE
  CATALOG_NAMESPACE = '<your_foundry_namespace>' -- Foundry 文件夹,例如 /FoundryNamespace/MyProject/tables 对应 'FoundryNamespace.MyProject.tables'
  REST_CONFIG = (
    CATALOG_NAME = 'foundry'
    CATALOG_URI = 'https://<your_foundry>/iceberg'
    CATALOG_API_TYPE = 'public'
    ACCESS_DELEGATION_MODE = VENDED_CREDENTIALS
  )

  REST_AUTHENTICATION = (
    TYPE = OAUTH
    OAUTH_TOKEN_URI = 'https://<your_foundry>/iceberg/v1/oauth/tokens'
    OAUTH_CLIENT_ID = '<client_id>'
    OAUTH_CLIENT_SECRET = '<client_secret>'
    OAUTH_ALLOWED_SCOPES = ( 'api:iceberg-read', 'api:iceberg-write' )
  );

2. 验证集成

  1. 运行以下查询验证集成配置是否正确。更多详情请参阅 Snowflake 文档 ↗
SELECT SYSTEM$VERIFY_CATALOG_INTEGRATION('<your_integration_name>');
  1. 验证您能否从 Foundry Iceberg REST 目录中列出命名空间 ↗列出 Iceberg 表 ↗
SELECT SYSTEM$LIST_NAMESPACES_FROM_CATALOG(
     '<your_integration_name>',
     '<your_foundry_folder>', -- Foundry 文件夹,例如 /FoundryNamespace/MyProject/tables 对应 'FoundryNamespace.MyProject.tables'
     1
 );
SELECT SYSTEM$LIST_ICEBERG_TABLES_FROM_CATALOG(
     '<your_integration_name>',
     '<your_foundry_folder>', -- Foundry 文件夹,例如 /FoundryNamespace/MyProject/tables 对应 'FoundryNamespace.MyProject.tables'
     1
 );

3. 注册并读取表

创建一个链接到 Foundry 表的表,并验证您能否从中读取数据。此操作仅从 Foundry 读取数据,不会覆盖或删除该表。

CREATE OR REPLACE ICEBERG TABLE <database>.<schema>.<name_your_table_in_snowflake>
    CATALOG = '<your_integration_name>'
    CATALOG_TABLE_NAME = '<table_rid>' -- 或 '<table_name_in_foundry>'
    CATALOG_NAMESPACE = 'foundry'  -- 或 '<table_namespace_in_foundry>',例如 /FoundryNamespace/MyProject/tables 对应 'FoundryNamespace.MyProject.tables'
    AUTO_REFRESH = TRUE;

SELECT * FROM <database>.<schema>.<name_your_table_in_snowflake>;

4. (可选)写入表

在 Snowflake 中向 Foundry Iceberg 表写入数据。

INSERT INTO <database>.<schema>.<name_your_table_in_snowflake> VALUES
    <value_1>,
    <value_2>,
    <value_3>;

5. (可选)将集成链接到数据库

  1. 创建一个链接到目录集成的新数据库:
CREATE DATABASE <name_your_integration_database>
  LINKED_CATALOG = (
    CATALOG = '<your_integration_name>'
  );
  1. 验证目录链接状态。更多详情请参阅 Snowflake 文档 ↗
SELECT SYSTEM$CATALOG_LINK_STATUS('<name_your_integration_database>');