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

The Root object this reference belongs to.

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)

abort_all_queries_async(if_exists: bool | None = None) PollingOperation[None]

An asynchronous version of abort_all_queries().

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

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_alter_async(warehouse: WarehouseModel) PollingOperation[None]

An asynchronous version of create_or_alter().

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

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
drop_async(if_exists: bool | None = None) PollingOperation[None]

An asynchronous version of drop().

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

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)

fetch_async() PollingOperation[WarehouseModel]

An asynchronous version of fetch().

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

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)

rename_async(new_name: str, if_exists: bool | None = None) PollingOperation[None]

An asynchronous version of rename().

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

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
resume_async(if_exists: bool | None = None) PollingOperation[None]

An asynchronous version of resume().

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

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
suspend_async(if_exists: bool | None = None) PollingOperation[None]

An asynchronous version of suspend().

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

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
use_warehouse_async() PollingOperation[None]

An asynchronous version of use_warehouse().

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