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