snowflake.core.iceberg_table.IcebergTableResource¶
- class snowflake.core.iceberg_table.IcebergTableResource(name: Annotated[str, Strict(strict=True)], collection: IcebergTableCollection)¶
Bases:
SchemaObjectReferenceMixin[IcebergTableCollection]Represents a reference to a Snowflake Iceberg table.
With this Iceberg table reference, you can fetch information about an Iceberg table, as well as perform certain actions on it.
Attributes
- database¶
The DatabaseResource this reference belongs to.
- fully_qualified_name¶
Return the fully qualified name of the object this reference points to.
- root¶
The Root object this reference belongs to.
Methods
- convert_to_managed(base_location: Annotated[str, Strict(strict=True)] | None = None, storage_serialization_policy: Annotated[str, Strict(strict=True)] | None = None, if_exists: bool = False) None¶
Convert Iceberg table using external Iceberg catalog into a table that uses Snowflake as the catalog.
- Parameters:
base_location (str, optional) – The path to a directory where Snowflake can write data and metadata files for the table.
storage_serialization_policy (str, optional) – Specifies the storage serialization policy for the table.
if_exists (bool, optional) – Whether to error if the Iceberg table doesn’t exist. Default is
False.
Examples
Converts an Iceberg table to managed table using its reference, errors if it doesn’t exist:
>>> iceberg_table.convert_to_managed()
Converts an Iceberg table to managed table using its reference, if it exists:
>>> iceberg_table.convert_to_managed(if_exists=True)
- convert_to_managed_async(base_location: Annotated[str, Strict(strict=True)] | None = None, storage_serialization_policy: Annotated[str, Strict(strict=True)] | None = None, if_exists: bool = False) PollingOperation[None]¶
An asynchronous version of
convert_to_managed().Refer to
PollingOperationfor more information on asynchronous execution and the return type.
- drop(if_exists: bool = False) None¶
Drop this Iceberg table.
- Parameters:
if_exists (bool, optional) – Whether to error if the Iceberg table doesn’t exist. Default is
False.
Examples
Deleting an Iceberg table using its reference, error if it doesn’t exist:
>>> iceberg_table_reference.drop()
Deleting an Iceberg table using its reference, if it exists:
>>> iceberg_table_reference.drop(if_exists=True)
- drop_async(if_exists: bool = False) PollingOperation[None]¶
An asynchronous version of
drop().Refer to
PollingOperationfor more information on asynchronous execution and the return type.
- fetch() IcebergTable¶
Fetch the details of an Iceberg table.
Examples
Fetching a reference to an Iceberg table to print its name:
>>> iceberg_table_reference = root.databases["my_db"].schemas["my_schema"].iceberg_tables["foo"] >>> my_iceberg_table = iceberg_table_reference.fetch() >>> print(my_iceberg_table.name)
- fetch_async() PollingOperation[IcebergTable]¶
An asynchronous version of
fetch().Refer to
PollingOperationfor more information on asynchronous execution and the return type.
- get_tags(with_lineage: bool | None = None) dict[TagResource, TagValue]¶
Fetch all tags assigned to this Iceberg table.
This operation requires an active warehouse.
- Parameters:
with_lineage (bool, optional) – Controls whether returned tag assignments include only tags directly set on the object (False) or also those inherited through Snowflake’s object hierarchy (True). Default is
None, which is equivalent toFalse.
Examples
Get tags set on an Iceberg table:
>>> iceberg_table_reference.get_tags()
- get_tags_async(with_lineage: bool | None = None) PollingOperation[dict[TagResource, TagValue]]¶
An asynchronous version of
get_tags().Refer to
PollingOperationfor more information on asynchronous execution and the return type.
- refresh(metadata_file_relative_path: Annotated[str, Strict(strict=True)] | None = None, if_exists: bool = False) None¶
Refresh the metadata for an Iceberg table that uses an external Iceberg catalog.
- Parameters:
metadata_file_relative_path (str, optional) – Specifies a metadata file path for a table created from Iceberg files in object storage.
if_exists (bool, optional) – Whether to error if the Iceberg table doesn’t exist. Default is
False.
Examples
To refresh an Iceberg table using its reference, error if it doesn’t exist:
>>> iceberg_table.refresh()
To refresh an Iceberg table using its reference, if it exists:
>>> iceberg_table.refresh(if_exists=True)
- refresh_async(metadata_file_relative_path: Annotated[str, Strict(strict=True)] | None = None, if_exists: bool = False) PollingOperation[None]¶
An asynchronous version of
refresh().Refer to
PollingOperationfor more information on asynchronous execution and the return type.
- resume_recluster(if_exists: bool = False) None¶
Resume reclustering for an Iceberg table.
- Parameters:
if_exists (bool, optional) – Whether to error if the Iceberg table doesn’t exist. Default is
False.
Examples
To resume reclustering for an Iceberg table using its reference, error if it doesn’t exist:
>>> iceberg_table.resume_recluster()
To resume reclustering for an Iceberg table using its reference, if it exists:
>>> iceberg_table.resume_recluster(if_exists=True)
- resume_recluster_async(if_exists: bool = False) PollingOperation[None]¶
An asynchronous version of
resume_recluster().Refer to
PollingOperationfor more information on asynchronous execution and the return type.
- set_tags(tags: dict[TagResource, TagValue], if_exists: bool | None = None) None¶
Set tags on this Iceberg table.
- Parameters:
if_exists (bool, optional) – Check the existence of this Iceberg table before setting the tags. Default is
None, which is equivalent toFalse.
Examples
Set tags on an Iceberg table:
>>> tag = root.databases["your-database"].schemas["your-schema"].tags["your-tag"] ... other_tag = root.databases["your-database"].schemas["your-schema"].tags["your-other-tag"] ... iceberg_table_reference.set_tags({tag: TagValue("your-value"), other_tag: TagValue("your-value")})
- set_tags_async(tags: dict[TagResource, TagValue], if_exists: bool | None = None) PollingOperation[None]¶
An asynchronous version of
set_tags().Refer to
PollingOperationfor more information on asynchronous execution and the return type.
- suspend_recluster(if_exists: bool = False) None¶
Suspend reclustering for an Iceberg table.
- Parameters:
if_exists (bool, optional) – Whether to error if the Iceberg table doesn’t exist. Default is
False.
Examples
To suspend reclustering for an Iceberg table using its reference, error if it doesn’t exist:
>>> iceberg_table.suspend_recluster()
To suspend reclustering for an Iceberg table using its reference, if it exists:
>>> iceberg_table.suspend_recluster(if_exists=True)
- suspend_recluster_async(if_exists: bool = False) PollingOperation[None]¶
An asynchronous version of
suspend_recluster().Refer to
PollingOperationfor more information on asynchronous execution and the return type.
- undrop() None¶
Undrop an Iceberg table.
- Parameters:
if_exists (bool, optional) – Whether to error if the Iceberg table doesn’t exist. Default is
False.
Examples
To undrop an Iceberg table using its reference, error if it doesn’t exist:
>>> iceberg_table.undrop()
To undrop an Iceberg table using its reference, if it exists:
>>> iceberg_table.undrop(if_exists=True)
- undrop_async() PollingOperation[None]¶
An asynchronous version of
undrop().Refer to
PollingOperationfor more information on asynchronous execution and the return type.
- unset_tags(tag_resources: set[TagResource], if_exists: bool | None = None) None¶
Unset tags from this Iceberg table.
- Parameters:
if_exists (bool, optional) – Check the existence of this Iceberg table before unsetting the tags. Default is
None, which is equivalent toFalse.
Examples
Unset tags from an Iceberg table:
>>> tag = root.databases["your-database"].schemas["your-schema"].tags["your-tag"] ... other_tag = root.databases["your-database"].schemas["your-schema"].tags["your-other-tag"] ... iceberg_table_reference.unset_tags({tag, other_tag})
- unset_tags_async(tag_resources: set[TagResource], if_exists: bool | None = None) PollingOperation[None]¶
An asynchronous version of
unset_tags().Refer to
PollingOperationfor more information on asynchronous execution and the return type.