Skip to main content

iceberg_tables

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

Overview

Nameiceberg_tables
TypeResource
Idsnowflake.tables.iceberg_tables

Fields

The following fields are returned by SELECT queries:

successful

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 (COMPATIBLE, OPTIMIZED)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectdatabase_name, schema_name, name, endpointDescribe an iceberg table
listselectdatabase_name, schema_name, endpointlike, startsWith, showLimit, fromName, deepLists the Apache Iceberg™ tables for which you have access privileges.
createinsertdatabase_name, schema_name, endpoint, namecreateMode, copyGrantsCreate a snowflake managed iceberg table (clone and undrop are separate subresources)
deletedeletedatabase_name, schema_name, name, endpointifExists, typeDrop an iceberg table
as_selectexecdatabase_name, schema_name, query, endpoint, namecreateMode, copyGrantsCreate a snowflake managed iceberg table as select
from_aws_glue_catalogexecdatabase_name, schema_name, endpoint, name, catalog_table_namecreateModeCreate an unmanaged iceberg table from AWS Glue catalog
from_deltaexecdatabase_name, schema_name, endpoint, name, base_locationcreateModeCreate an unmanaged iceberg table from Delta
from_iceberg_filesexecdatabase_name, schema_name, endpoint, name, metadata_file_pathcreateModeCreate an unmanaged iceberg table from Iceberg files
from_iceberg_restexecdatabase_name, schema_name, endpoint, name, catalog_table_namecreateModeCreate an unmanaged iceberg table from Iceberg REST
resume_reclusterexecdatabase_name, schema_name, name, endpointifExistsResume recluster of an iceberg table (iceberg tables managed by an external catalog do not allow clustering)
suspend_reclusterexecdatabase_name, schema_name, name, endpointifExistsSuspend recluster of an iceberg table (iceberg tables managed by an external catalog do not allow clustering)
refreshexecdatabase_name, schema_name, name, endpointifExistsRefreshes the metadata for an Apache Iceberg table that uses an external Iceberg catalog
convert_to_managedexecdatabase_name, schema_name, name, endpointifExistsConvert unmanaged iceberg table to managed iceberg table
undropexecdatabase_name, schema_name, name, endpointUndrop an iceberg table
cloneexecdatabase_name, schema_name, name, endpoint, namecreateMode, copyGrants, targetDatabase, targetSchemaClone a snowflake managed iceberg table
create_likeexecdatabase_name, schema_name, name, endpoint, namecreateMode, 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 identifier (orgname-accountname) (default: orgname-accountname)
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.
copyGrantsbooleanParameter to enable copy grants when creating the object.
createModestringParameter 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.
fromNamestringParameter 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.
ifExistsbooleanParameter 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.
likestringParameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters.
showLimitintegerParameter to limit the maximum number of rows returned by a command.
startsWithstringParameter 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

Describe an iceberg table

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.tables.iceberg_tables
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND name = '{{ name }}' -- required
AND endpoint = '{{ endpoint }}' -- required
;

INSERT examples

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

INSERT INTO snowflake.tables.iceberg_tables (
name,
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
)
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 }}'
RETURNING
status
;

DELETE examples

Drop an iceberg table

DELETE FROM snowflake.tables.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.tables.iceberg_tables.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 }}"
}'
;