Connect to an open-sharing catalog¶
This topic is for external consumers: people or workloads outside Snowflake that read data that a provider shares through Open Data Sharing. You connect by using any engine or tool that supports the Apache Iceberg™ REST Catalog (IRC) API. This topic uses Apache Spark™ as an example.
The connection works the same way as accessing Iceberg tables with an external engine through Snowflake Horizon Catalog. For more background, see Access Apache Iceberg™ tables with an external engine through Snowflake Horizon Catalog.
Before you begin¶
Get the following information from the data provider:
- The connection values for the listing: the catalog name (
catalog), catalog URI (catalog_uri), OAuth scope (scope), and OAuth token URI (oauth_token_uri). The provider retrieves these values for you by calling SYSTEM$GET_LISTING_URL_FOR_EXTERNAL_CONSUMER. The scope is alwayssession:role:external. - Your credentials, which depend on the authentication method the provider configured:
- Workload identity federation (WIF): The identity provider type (
AWS,AZURE,GCP, orOIDC) and the identity the provider registered for you, such as an AWS IAM role ARN, an Azure managed identity, a Google Cloud service account, or an OIDC issuer and subject. Your workload must run as that identity. - Programmatic access token (PAT): The PAT secret.
- Workload identity federation (WIF): The identity provider type (
How authentication works¶
Your client exchanges a credential for a short-lived access token at the catalog’s OAuth token endpoint, then uses that access token
for catalog requests. Most IRC clients, including Spark, perform this exchange for you when you set the credential and scope
properties.
The token request uses the following parameters:
| Parameter | Value |
|---|---|
grant_type | client_credentials |
scope | session:role:external |
client_secret | With a PAT, the PAT secret. With WIF, the OpenID Connect (OIDC) token from your identity provider. |
With WIF, you must also send the X-Snowflake-Workload-Identity-Provider header. Set it to the TYPE of the workload identity that
the provider registered for you: AWS, AZURE, GCP, or OIDC. These are the same TYPE values that
ALTER USER … ADD WORKLOAD IDENTITY uses.
The following example requests an access token with a PAT:
The following example requests an access token with WIF:
Where:
<oauth_token_uri>is the OAuth token URI that the provider gave you.<pat_secret>is the PAT secret that the provider gave you.<provider>is theTYPEof your workload identity:AWS,AZURE,GCP, orOIDC. For more information about workload identity types, see ALTER USER … ADD WORKLOAD IDENTITY.<oidc_token>is the OIDC token that your workload obtains from its identity provider at runtime. For background on how workloads obtain tokens from each identity provider, see Workload identity federation.
Connect with Apache Spark™¶
Choose the example that matches your authentication method. Both examples set the following:
spark.sql.iceberg.vectorization.enabledtofalse, which is required to read Open Data Sharing tables.- The Iceberg bundle for the cloud that hosts the listing. The examples use
iceberg-aws-bundle. If the provider’s listing is served from a Microsoft Azure region, useorg.apache.iceberg:iceberg-azure-bundleinstead.
Pass the OIDC token from your identity provider as the credential, and add the X-Snowflake-Workload-Identity-Provider header.
Because the token is short-lived, fetch it at runtime when you create the Spark session.
Pass the PAT secret as the credential.
Where:
<catalog_uri>and<catalog_name>are the catalog URI and catalog name that the provider gave you.<provider>is theTYPEof your workload identity:AWS,AZURE,GCP, orOIDC.<oidc_token>is the OIDC token that your workload obtains from its identity provider at runtime.<pat_secret>is the PAT secret that the provider gave you.
After you connect, query the shared tables:
Shared data is read-only. Write operations aren’t supported.