SQL
The SQL
Post-hook executes a Snowflake query after the main query completes.
This query can look at the outcome of the main query and record telemetry information or shutdown idle warehouses. This query is executed in parallel to results return of the main query so main query latency should not be impacted. Additional user queries submitted immediately after the main query returns may be executed prior to or in parallel to this query. This query is typically run within 1-2s after the main query is completed.
{
'queryText': <query>
}
<query>
- The text of the SQL to run after the user’s query completes
- A post-hook runs asynchronously after the user’s query completes, so if multiple are defined, their run order is undefined
CREATE SUNDECK FLOW MANAGE_WH
POST HOOK SHRINK_WH
ALWAYS
SQL {
'sqlText': 'BEGIN
CALL my_co.is_after_business_hours() INTO :is_open;
IF (is_open) THEN
ALTER WAREHOUSE my_wh SET warehouse_size=SMALL;
END IF;
END'
}
;
This example creates a flow with a post-hook that sets the warehouse size to SMALL
if running after business hours