snowflake.core.warehouse.WarehouseResource

class snowflake.core.warehouse.WarehouseResource(name: str, collection: WarehouseCollection)

Bases: ObjectReferenceMixin[WarehouseCollection]

A reference to a Warehouse in Snowflake.

Attributes

root

Methods

__init__(name: str, collection: WarehouseCollection)
abort_all_queries() None

Abort all queries running or queueing on this warehouse.

Example

Use warehouse reference to abort all queries:

>>> warehouse = warehouse_reference.abort_all_queries()
Copy
create_or_update(warehouse: WarehouseModel) None

Create a warehouse in Snowflake or update one if it already exists.

Parameters:

warehouse – an instance of Warehouse.

Example

Create a warehouse on Snowflake server and get the reference to it:

>>> from snowflake.core.warehouse import Warehouse
>>> warehouse_parameters = Warehouse(
...     name="your-warehouse-name",
...     warehouse_size="SMALL",
...     auto_suspend=500,
...)
>>> # Use warehouse collection to create a reference to warehouse resource in Snowflake server.
>>> root.warehouses["your-warehouse-name"].create_or_update(warehouse_parameters)
Copy
delete() None

Delete this warehouse.

Example

Use warehouse reference to delete a warehouse:

>>> warehouse_reference.delete()
Copy
fetch() WarehouseModel

Retrieve the warehouse resource.

Example

Use warehouse reference to fetch a warehouse:

>>> from snowflake.core.warehouse import Warehouse
>>> warehouse = warehouse_reference.fetch()
>>> # Access information of the warehouse with warehouse instance.
>>> print(warehouse.name, warehouse.warehouse_size)
Copy
rename(new_name: str) None

Rename this warehouse.

This function will ignore other parameters in warehous instance, use create_or_update() to udpate parameters.

Parameters:

new_name – an instance of Warehouse.

Example

Use warehouse reference to renane a warehouse:

>>> from snowflake.core.warehouse import Warehouse
>>> new_warehouse = Warehouse(
...     name="new_warehouse_name"
...)
>>> warehouse = warehouse_reference.rename(new_warehouse)
Copy
resume() None

Resume the warehouse.

Example

Use warehouse reference to resume a warehouse:

>>> warehouse_reference.resume()
Copy
suspend() None

Suspend the warehouse.

Example

Use warehouse reference to suspend a warehouse:

>>> from snowflake.core.warehouse import WarehouseResource
>>> warehouse_reference.suspend()
Copy