snowflake.core.dynamic_table.DynamicTableCollection¶
- class snowflake.core.dynamic_table.DynamicTableCollection(schema: SchemaResource)¶
- Bases: - DynamicTableCollectionBase- Represents the collection operations on the Snowflake Dynamic Table resource. - With this collection, you can create, iterate through, and search for dynamic tables that you have access to in the current context. - Examples - Creating a dynamic table instance: - >>> dynamic_tables = root.databases["my_db"].schemas["my_schema"].dynamic_tables >>> dynamic_tables.create( ... DynamicTable( ... name="my_dynamic_table", ... columns=[ ... DynamicTableColumn(name="c1"), ... DynamicTableColumn(name='"cc2"', datatype="varchar"), ... ], ... warehouse=db_parameters["my_warehouse"], ... target_lag=UserDefinedLag(seconds=60), ... query="SELECT * FROM my_table", ... ), ... mode=CreateMode.error_if_exists, ... ) - Attributes - database¶
- The DatabaseResource this collection belongs to. 
 - root¶
- The Root object this collection belongs to. 
 - Methods - create(table: DynamicTable | DynamicTableClone | str, *, clone_table: str | Clone | None = None, copy_grants: bool | None = False, mode: CreateMode = CreateMode.error_if_exists) DynamicTableResource¶
- Create a dynamic table. - Parameters:
- table (DynamicTable | DynamicTableClone | str) – - The DynamicTableobject, together with the dynamic table’s properties:
- name, target_lag, warehouse, query; columns, refresh_mode, initialize, cluster_by, comment are optional. 
 
- The 
- The - DynamicTableCloneobject, when it’s used with clone_table.
- The table name. 
 
- clone_table (Clone, optional) – The source table to clone from. 
- copy_grants (bool, optional) – Whether to enable copy grants when creating the object. Default is - False.
- mode (CreateMode, optional) – - One of the following enum values. - CreateMode.error_if_exists: Throw an- snowflake.core.exceptions.ConflictErrorif the dynamic table already exists in Snowflake. Equivalent to SQL- create dynamic table <name> ....- CreateMode.or_replace: Replace if the dynamic table already exists in Snowflake. Equivalent to SQL- create or replace dynamic table <name> ....- CreateMode.if_not_exists: Do nothing if the dynamic table already exists in Snowflake. Equivalent to SQL- create dynamic table <name> if not exists...- Default is - CreateMode.error_if_exists.
 
 - Examples - Creating a dynamic table, replacing any existing dynamic table with the same name: - >>> dynamic_tables = root.databases["my_db"].schemas["my_schema"].dynamic_tables >>> dynamic_tables.create( ... DynamicTable( ... name="my_dynamic_table", ... columns=[ ... DynamicTableColumn(name="c1"), ... DynamicTableColumn(name='"cc2"', datatype="varchar"), ... ], ... warehouse=db_parameters["my_warehouse"], ... target_lag=UserDefinedLag(seconds=60), ... query="SELECT * FROM my_table", ... ), ... mode=CreateMode.error_if_exists, ... ) - Creating a dynamic table by cloning an existing table: - >>> dynamic_tables = root.databases["my_db"].schemas["my_schema"].dynamic_tables >>> dynamic_tables.create( ... DynamicTableClone( ... name="my_dynamic_table", ... target_lag=UserDefinedLag(seconds=120), ... ), ... clone_table=Clone( ... source="my_source_dynamic_table", ... point_of_time=PointOfTimeOffset(reference="before", when="-1"), ... ), ... copy_grants=True, ... ) - Creating a dynamic table by cloning an existing table in a different database and schema: - >>> dynamic_tables = root.databases["my_db"].schemas["my_schema"].dynamic_tables >>> dynamic_tables.create( ... DynamicTableClone( ... name="my_dynamic_table", ... target_lag=UserDefinedLag(seconds=120), ... ), ... clone_table=Clone( ... source="database_of_source_table.schema_of_source_table.my_source_dynamic_table", ... point_of_time=PointOfTimeOffset(reference="before", when="-1"), ... ), ... copy_grants=True, ... ) 
 - create_async(table: DynamicTable | DynamicTableClone | str, *, clone_table: str | Clone | None = None, copy_grants: bool | None = False, mode: CreateMode = CreateMode.error_if_exists) PollingOperation[DynamicTableResource]¶
- An asynchronous version of - create().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - items() ItemsView[str, T]¶
 - iter(*, like: str | None = None, starts_with: str | None = None, limit: int | None = None, from_name: str | None = None, deep: bool | None = None, show_limit: int | None = None) Iterator[DynamicTable]¶
- List dynamic tables. - Parameters:
- like (str) – Parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters. 
- starts_with (str) – 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. 
- limit (int) – Parameter to limit the maximum number of rows returned by a command. 
- from_name (str) – 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. 
- deep (bool) – Optionally includes dependency information of the dynamic table. 
 
 
 - iter_async(*, like: str | None = None, starts_with: str | None = None, limit: int | None = None, from_name: str | None = None, deep: bool | None = None, show_limit: int | None = None) PollingOperation[Iterator[DynamicTable]]¶
- An asynchronous version of - iter().- Refer to - PollingOperationfor more information on asynchronous execution and the return type.
 - keys() KeysView[str]¶
 - update_reference(old_name: str, new_name: str, resource: T) None¶
- Update the collection with a new item. 
 - values() ValuesView[T]¶