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 fetch information about a warehouse, as well as perform certain actions on it.

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.

get_tags(with_lineage: bool | None = None) dict[TagResource, TagValue]

Get the tag assignments for a warehouse.

Returns all tags assigned to a warehouse. This operation requires an active warehouse.

Parameters:

with_lineage (bool, optional) – Parameter that specifies whether tag assignments inherited by the object from its ancestors in securable object hierarchy should be returned as well: - true: All tags assigned to this object should be returned, inheritance included. - false: Only tags explicitly assigned to this object should be returned.

get_tags_async(with_lineage: bool | None = None) PollingOperation[dict[TagResource, TagValue]]

An asynchronous version of get_tags().

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.

set_tags(tags: dict[TagResource, TagValue], if_exists: bool | None = None) None

Set tags on a warehouse.

Parameters:
  • tags (dict[TagResource, TagValue]) – (required)

  • if_exists (bool) – Parameter that specifies how to handle the request for a resource that does not exist: - true: The endpoint does not throw an error if the resource does not exist. It returns a 200 success response, but does not take any action on the resource. - false: The endpoint throws an error if the resource doesn’t exist.

set_tags_async(tags: dict[TagResource, TagValue], if_exists: bool | None = None) PollingOperation[None]

An asynchronous version of set_tags().

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.

unset_tags(tag_resources: set[TagResource], if_exists: bool | None = None) None

Unset tags from a warehouse.

Parameters:
  • tag_resources (set[TagResource]) – (required)

  • if_exists (bool) – Parameter that specifies how to handle the request for a resource that does not exist: - true: The endpoint does not throw an error if the resource does not exist. It returns a 200 success response, but does not take any action on the resource. - false: The endpoint throws an error if the resource doesn’t exist.

unset_tags_async(tag_resources: set[TagResource], if_exists: bool | None = None) PollingOperation[None]

An asynchronous version of unset_tags().

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.