Query a table in Polaris using Snowflake¶
To query a table registered in Polaris Catalog using Snowflake, you can create a Snowflake Iceberg table that uses an external catalog.
The Iceberg table represents the table in Polaris and provides read-only access.
Prerequisites¶
Before you start, you need the following:
An Apache Iceberg™ table registered with Polaris Catalog.
A service connection that Snowflake can use to connect to Polaris. You can use an existing service connection that you’ve set up roles and privileges for, or Configure a service connection for Snowflake. If you configure a new service connection, you must also configure access control for it.
Step 1: Create an external volume in Snowflake¶
If you don’t have one already, start by creating an external volume in Snowflake that provides access to the cloud storage location where you store your table data and metadata.
Complete the instructions for your cloud storage service:
Step 2: Create a catalog integration for Polaris¶
Next, use the CREATE CATALOG INTEGRATION (Polaris Catalog) command to create a catalog integration in Snowflake that uses OAuth to connect to Polaris using your service connection credentials.
CREATE OR REPLACE CATALOG INTEGRATION polaris_catalog_int
CATALOG_SOURCE = POLARIS
TABLE_FORMAT = ICEBERG
CATALOG_NAMESPACE= 'myPolarisCatalogNamespace'
REST_CONFIG = (
CATALOG_URI ='https://my_account.snowflakecomputing.com/polaris/api/catalog'
WAREHOUSE = 'myPolarisCatalogName'
)
REST_AUTHENTICATION = (
TYPE = OAUTH
OAUTH_CLIENT_ID = 'my-client-id'
OAUTH_CLIENT_SECRET = 'my-client-secret'
OAUTH_ALLOWED_SCOPES = ( 'PRINCIPAL_ROLE:ALL' )
)
ENABLED = TRUE;
Step 3: Create an externally managed Iceberg table¶
Create an Iceberg table in Snowflake using the external volume and catalog integration that you previously configured.
For CATALOG_TABLE_NAME, specify the table name as it appears in Polaris.
CREATE ICEBERG TABLE polaris_iceberg_table
CATALOG = 'polaris_catalog_int'
EXTERNAL_VOLUME = 'my_external_volume'
CATALOG_TABLE_NAME = 'my_iceberg_table';
Step 4: Query the table using Snowflake¶
You can now use Snowflake to query the table in Polaris. You can also join the query results with other Snowflake tables.
SELECT id, date
FROM polaris_iceberg_table
LIMIT 10;