snowflake.core.warehouse.WarehouseCollection¶
- class snowflake.core.warehouse.WarehouseCollection(root: Root)¶
Bases:
AccountObjectCollectionParent
[WarehouseResource
]Represents the collection operations of the Snowflake Warehouse resource.
With this collection, you can create, iterate through, and search for warehouses that you have access to in the current context.
Examples
Creating a warehouse instance:
>>> warehouses = root.warehouses >>> new_wh = Warehouse( ... name="my_wh", ... warehouse_size="XSMALL") >>> warehouses.create(new_wh)
Attributes
- root¶
Methods
- create(warehouse: WarehouseModel, *, mode: CreateMode = CreateMode.error_if_exists) WarehouseResource ¶
Create a warehouse in Snowflake.
- Parameters:
warehouse (Warehouse)
mode (CreateMode, optional) –
One of the below enum values.
CreateMode.error_if_exists
: Throw ansnowflake.core.exceptions.ConflictError
if the warehouse already exists in Snowflake. Equivalent to SQLcreate warehouse <name> ...
.CreateMode.or_replace
: Replace if the warehouse already exists in Snowflake. Equivalent to SQLcreate or replace warehouse <name> ...
.CreateMode.if_not_exists
: Do nothing if the warehouse already exists in Snowflake. Equivalent to SQLcreate warehouse <name> if not exists...
Default value is
CreateMode.error_if_exists
.
Examples
Creating a warehouse in Snowflake and getting the reference to it:
>>> warehouse_parameters = Warehouse( ... name="your-warehouse-name", ... warehouse_size="SMALL", ... auto_suspend=500, ...)
>>> # Use the warehouse collection created before to create a reference to a warehouse resource >>> # in Snowflake. >>> warehouse_reference = warehouse_collection.create(warehouse_parameters)
- items() ItemsView[str, T] ¶
- iter(*, like: str | None = None) Iterator[WarehouseModel] ¶
Iterate through
Warehouse
objects in Snowflake, filtering on any optional like pattern.- Parameters:
like (str, optional) – A case-insensitive string functioning as a filter, with support for SQL wildcard characters (% and _).
Examples
Showing all warehouses that you have access to see:
>>> warehouses = warehouse_collection.iter()
Showing information of the exact warehouse you want to see:
>>> warehouses = warehouse_collection.iter(like="your-warehouse-name")
Showing warehouses starting with ‘your-warehouse-name-‘:
>>> warehouses = warehouse_collection.iter(like="your-warehouse-name-%")
Using a for loop to retrieve information from iterator:
>>> for warehouse in warehouses: >>> print(warehouse.name, warehouse.warehouse_size)
- keys() KeysView[str] ¶
- values() ValuesView[T] ¶