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()
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.
Examples
Creating or updating a warehouse in Snowflake:
>>> warehouse_parameters = Warehouse( ... name="your-warehouse-name", ... warehouse_size="SMALL", ... auto_suspend=500, ...)
# 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()
Dropping a warehouse using its reference, if it exists:
>>> warehouse_reference.drop(if_exists=True)
- fetch() WarehouseModel ΒΆ
Fetch the details of a warehouse.
Examples
Fetching a warehouse using its reference:
>>> warehouse = warehouse_reference.fetch()
# 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:
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()
Using a warehouse reference to resume a warehouse if it exists:
>>> warehouse_reference.resume(if_exists=True)
- 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 toFalse
.
Examples
Using a warehouse reference to suspend a warehouse, erroring if it does not exist:
>>> warehouse_reference.suspend()
Using a warehouse reference to suspend a warehouse if it exists:
>>> warehouse_reference.suspend(if_exists=True)
- 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()