snowflake.core.warehouse.WarehouseResource

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

Bases: ObjectReferenceMixin[WarehouseCollection]

Represents a reference to a Snowflake warehouse.

With this warehouse reference, you can create, update, and fetch information about warehouses, as well as perform certain actions on them.

Attributes

root

Methods

abort_all_queries(if_exists: bool | None = None) None

Abort all queries running or queueing on this warehouse.

Parameters:

if_exists (bool, optional) – If set to True, the function will not throw an error if the warehouse does not exist. The default is None, which is equivalent to False.

Examples

Using a warehouse reference to abort all queries, erroring if it does not exist:

>>> warehouse = warehouse_reference.abort_all_queries()
Copy

Using a warehouse reference to abort all queries, if it exists: >>> warehouse = warehouse_reference.abort_all_queries(if_exists=True)

create_or_alter(warehouse: WarehouseModel) None

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

Parameters:

warehouse (Warehouse) – An instance of Warehouse.

Examples

Creating or updating a warehouse in Snowflake:

>>> warehouse_parameters = Warehouse(
...     name="your-warehouse-name",
...     warehouse_size="SMALL",
...     auto_suspend=500,
...)
Copy

# Using a WarehouseCollection to create or update a warehouse in Snowflake: >>> root.warehouses[“your-warehouse-name”].create_or_alter(warehouse_parameters)

create_or_update(warehouse: WarehouseModel) None

The create_or_update method is deprecated; use create_or_alter instead.

delete(if_exists: bool | None = None) None

The delete method is deprecated; use drop instead.

drop(if_exists: bool | None = None) None

Drop this warehouse.

Parameters:

if_exists (bool, optional) – If set to True, the function will not throw an error if the warehouse does not exist. The default is None, which is equivalent to False.

Examples

Dropping a warehouse using its reference, erroring if it does not exist:

>>> warehouse_reference.drop()
Copy

Dropping a warehouse using its reference, if it exists:

>>> warehouse_reference.drop(if_exists=True)
Copy
fetch() WarehouseModel

Fetch the details of a warehouse.

Examples

Fetching a warehouse using its reference:

>>> warehouse = warehouse_reference.fetch()
Copy

# Accessing information of the warehouse with warehouse instance. >>> print(warehouse.name, warehouse.warehouse_size)

rename(new_name: str, if_exists: bool | None = None) None

Rename this warehouse.

This function will ignore other parameters in warehouse instance; use create_or_update() to update parameters.

Parameters:
  • new_name (Warehouse) – An instance of Warehouse.

  • if_exists (bool, optional) – If set to True, the function will not throw an error if the warehouse does not exist. The default is None, which is equivalent to False.

Examples

Using a warehouse reference to rename a warehouse in Snowflake, erroring if it does not exist: >>> warehouse_reference.rename(“new_wh_name”)

Using a warehouse reference to rename a warehouse in Snowflake, if it exists: >>> warehouse_reference.rename(“new_wh_name”, if_exists=True)

resume(if_exists: bool | None = None) None

Resume the warehouse.

Parameters:

if_exists (bool, optional) – If set to True, the function will not throw an error if the warehouse does not exist. The default is None, which is equivalent to False.

Examples

Using a warehouse reference to resume a warehouse, erroring if it does not exist:

>>> warehouse_reference.resume()
Copy

Using a warehouse reference to resume a warehouse if it exists:

>>> warehouse_reference.resume(if_exists=True)
Copy
suspend(if_exists: bool | None = None) None

Suspend the warehouse.

Parameters:

if_exists (bool, optional) – Check the existence of this warehouse before suspending it. Default is None, which is equivalent to False.

Examples

Using a warehouse reference to suspend a warehouse, erroring if it does not exist:

>>> warehouse_reference.suspend()
Copy

Using a warehouse reference to suspend a warehouse if it exists:

>>> warehouse_reference.suspend(if_exists=True)
Copy
use_warehouse() None

Use this warehouse as the current warehouse.

Examples

Using a warehouse reference to set the current active warehouse:

>>> warehouse_reference.use_warehouse()
Copy