snowflake.core.warehouse.WarehouseCollection | Snowflake Documentation (original) (raw)

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

The Root object this collection belongs to.

Methods

create(warehouse: WarehouseModel, *, mode: CreateMode = CreateMode.error_if_exists) → WarehouseResource

Create a warehouse in Snowflake.

Parameters:

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)

create_async(warehouse: WarehouseModel, *, mode: CreateMode = CreateMode.error_if_exists) → PollingOperation[WarehouseResource]

An asynchronous version of create().

Refer to PollingOperation for more information on asynchronous execution and the return type.

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)

iter_async(*, like: str | None = None) → PollingOperation[Iterator[WarehouseModel]]

An asynchronous version of iter().

Refer to PollingOperation for more information on asynchronous execution and the return type.

keys() → KeysView[str]

values() → ValuesView[T]