Skip to main content

iceberg_tables

Creates, updates, deletes, gets or lists an iceberg_tables resource.

Overview

Nameiceberg_tables
TypeResource
Idsnowflake.iceberg_table.iceberg_tables

Fields

The following fields are returned by SELECT queries:

A Snowflake iceberg table

NameDatatypeDescription
namestringName of the iceberg table (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$)
catalog_table_namestringName of the table as recognized by the catalog.
database_namestringDatabase in which the iceberg table is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$)
schema_namestringSchema in which the iceberg table is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$)
auto_refreshbooleanSpecifies whether to automatically refresh the table metadata
base_locationstringThe path to a directory where Snowflake can write data and metadata files for the table.
can_write_metadatastringSignifies whether Snowflake can write metadata to the location specified by the file_path.
catalogstringName of the catalog integration to use for iceberg tables
catalog_namespacestringCatalog namespace for the table. The namespace defined when the table was created. Otherwise, the default namespace associated with the catalog integration used by the table. If you’re syncing the table to Snowflake Open Catalog, the default is null.
catalog_syncstringName of the catalog integration to sync this table
change_trackingbooleanTrue if change tracking is enabled, allowing streams and CHANGES to be used on the entity.
cluster_byarraySpecifies one or more columns or column expressions in the table as the clustering key.
columnsarray
commentstringuser comment associated to an object in the dictionary
constraintsarray
created_onstring (date-time)Date and time when the iceberg table was created.
data_retention_time_in_daysintegernumber of days to retain the old version of deleted/updated data
external_volumestringName of an external volume that will be used for persisted Iceberg metadata and data files.
iceberg_table_typestringType of Iceberg table. UNMANAGED if the table is not managed by Snowflake. NOT ICEBERG otherwise.
max_data_extension_time_in_daysintegerMaximum number of days to extend data retention beyond the retention period to prevent a stream becoming stale.
metadata_file_pathstringSpecifies the relative path of the Iceberg metadata file to use for column definitions.
ownerstringRole that owns the iceberg table (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$)
owner_role_typestringThe type of role that owns the iceberg table (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$)
replace_invalid_charactersbooleanSpecifies whether to replace invalid characters in the column names
storage_serialization_policystringStorage serialization policy used for managed Iceberg table. This include encodings and compressions

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
list_iceberg_tablesselectdatabase_name, schema_name, endpointlike, startsWith, showLimit, fromName, deepLists the Apache Iceberg™ tables for which you have access privileges.
fetch_iceberg_tableselectdatabase_name, schema_name, name, endpointDescribe an iceberg table
create_snowflake_managed_iceberg_tableinsertdatabase_name, schema_name, endpointcreateMode, copyGrantsCreate a snowflake managed iceberg table (clone and undrop are separate subresources)
drop_iceberg_tabledeletedatabase_name, schema_name, name, endpointifExists, typeDrop an iceberg table
create_snowflake_managed_iceberg_table_as_selectexecdatabase_name, schema_name, query, endpointcreateMode, copyGrantsCreate a snowflake managed iceberg table as select
create_unmanaged_iceberg_table_from_aws_glue_catalogexecdatabase_name, schema_name, endpointcreateModeCreate an unmanaged iceberg table from AWS Glue catalog
create_unmanaged_iceberg_table_from_deltaexecdatabase_name, schema_name, endpointcreateModeCreate an unmanaged iceberg table from Delta
create_unmanaged_iceberg_table_from_iceberg_filesexecdatabase_name, schema_name, endpointcreateModeCreate an unmanaged iceberg table from Iceberg files
create_unmanaged_iceberg_table_from_iceberg_restexecdatabase_name, schema_name, endpointcreateModeCreate an unmanaged iceberg table from Iceberg REST
resume_recluster_iceberg_tableexecdatabase_name, schema_name, name, endpointifExistsResume recluster of an iceberg table (iceberg tables managed by an external catalog do not allow clustering)
suspend_recluster_iceberg_tableexecdatabase_name, schema_name, name, endpointifExistsSuspend recluster of an iceberg table (iceberg tables managed by an external catalog do not allow clustering)
refresh_iceberg_tableexecdatabase_name, schema_name, name, endpointifExistsRefreshes the metadata for an Apache Iceberg table that uses an external Iceberg catalog
convert_to_managed_iceberg_tableexecdatabase_name, schema_name, name, endpointifExistsConvert unmanaged iceberg table to managed iceberg table
undrop_iceberg_tableexecdatabase_name, schema_name, name, endpointUndrop an iceberg table
clone_snowflake_managed_iceberg_tableexecdatabase_name, schema_name, name, endpointcreateMode, copyGrants, targetDatabase, targetSchemaClone a snowflake managed iceberg table
create_snowflake_managed_iceberg_table_likeexecdatabase_name, schema_name, name, endpointcreateMode, copyGrants, targetDatabase, targetSchemaCreates a new table with the same column definitions as an existing table, but without copying data from the existing table.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
database_namestringIdentifier (i.e. name) for the database to which the resource belongs. You can use the /api/v2/databases GET request to get a list of available databases.
endpointstringOrganization and Account Name (default: orgid-acctid)
namestringIdentifier (i.e. name) for the resource.
querystringThe SQL select query to run to set up the table values (and possibly columns).
schema_namestringIdentifier (i.e. name) for the schema to which the resource belongs. You can use the /api/v2/databases/{database}/schemas GET request to get a list of available schemas for the specified database.
copyGrantsbooleanQuery parameter to enable copy grants when creating the object.
createModestringQuery parameter allowing support for different modes of resource creation. Possible values include: - errorIfExists: Throws an error if you try to create a resource that already exists. - orReplace: Automatically replaces the existing resource with the current one. - ifNotExists: Creates a new resource when an alter is requested for a non-existent resource.
deepbooleanOptionally includes dependency information of the table.
fromNamestringQuery parameter to enable fetching rows only following the first row whose object name matches the specified string. Case-sensitive and does not have to be the full name.
ifExistsbooleanQuery parameter that specifies how to handle the request for a resource that does not exist: - true: The endpoint does not throw an error if the resource does not exist. It returns a 200 success response, but does not take any action on the resource. - false: The endpoint throws an error if the resource doesn't exist.
likestringQuery parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters.
showLimitintegerQuery parameter to limit the maximum number of rows returned by a command.
startsWithstringQuery parameter to filter the command output based on the string of characters that appear at the beginning of the object name. Uses case-sensitive pattern matching.
targetDatabasestringDatabase of the newly created table. Defaults to the source table's database.
targetSchemastringSchema of the newly created table. Defaults to the source table's schema.
typestringSpecifies whether the table can be dropped if foreign keys exist that reference the table.

SELECT examples

Lists the Apache Iceberg™ tables for which you have access privileges.

SELECT
name,
catalog_table_name,
database_name,
schema_name,
auto_refresh,
base_location,
can_write_metadata,
catalog,
catalog_namespace,
catalog_sync,
change_tracking,
cluster_by,
columns,
comment,
constraints,
created_on,
data_retention_time_in_days,
external_volume,
iceberg_table_type,
max_data_extension_time_in_days,
metadata_file_path,
owner,
owner_role_type,
replace_invalid_characters,
storage_serialization_policy
FROM snowflake.iceberg_table.iceberg_tables
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND endpoint = '{{ endpoint }}' -- required
AND like = '{{ like }}'
AND startsWith = '{{ startsWith }}'
AND showLimit = '{{ showLimit }}'
AND fromName = '{{ fromName }}'
AND deep = '{{ deep }}';

INSERT examples

Create a snowflake managed iceberg table (clone and undrop are separate subresources)

INSERT INTO snowflake.iceberg_table.iceberg_tables (
data__name,
data__comment,
data__change_tracking,
data__max_data_extension_time_in_days,
data__external_volume,
data__data_retention_time_in_days,
data__catalog_sync,
data__catalog,
data__storage_serialization_policy,
data__catalog_table_name,
data__catalog_namespace,
data__cluster_by,
data__columns,
data__base_location,
data__replace_invalid_characters,
data__metadata_file_path,
data__constraints,
database_name,
schema_name,
endpoint,
createMode,
copyGrants
)
SELECT
'{{ name }}' --required,
'{{ comment }}',
{{ change_tracking }},
{{ max_data_extension_time_in_days }},
'{{ external_volume }}',
{{ data_retention_time_in_days }},
'{{ catalog_sync }}',
'{{ catalog }}',
'{{ storage_serialization_policy }}',
'{{ catalog_table_name }}',
'{{ catalog_namespace }}',
'{{ cluster_by }}',
'{{ columns }}',
'{{ base_location }}',
{{ replace_invalid_characters }},
'{{ metadata_file_path }}',
'{{ constraints }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}',
'{{ createMode }}',
'{{ copyGrants }}'
;

DELETE examples

Drop an iceberg table

DELETE FROM snowflake.iceberg_table.iceberg_tables
WHERE database_name = '{{ database_name }}' --required
AND schema_name = '{{ schema_name }}' --required
AND name = '{{ name }}' --required
AND endpoint = '{{ endpoint }}' --required
AND ifExists = '{{ ifExists }}'
AND type = '{{ type }}';

Lifecycle Methods

Create a snowflake managed iceberg table as select

EXEC snowflake.iceberg_table.iceberg_tables.create_snowflake_managed_iceberg_table_as_select 
@database_name='{{ database_name }}' --required,
@schema_name='{{ schema_name }}' --required,
@query='{{ query }}' --required,
@endpoint='{{ endpoint }}' --required,
@createMode='{{ createMode }}',
@copyGrants={{ copyGrants }}
@@json=
'{
"name": "{{ name }}",
"columns": "{{ columns }}",
"external_volume": "{{ external_volume }}",
"cluster_by": "{{ cluster_by }}",
"base_location": "{{ base_location }}",
"comment": "{{ comment }}"
}';