Documentation
Toggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

Workload Routing

The WORKLOAD_ROUTING Pre-hook routes queries to warehouses based on a workload tag, which is a Sundeck extension to the client connection’s WAREHOUSE parameter.

When connecting to Snowflake, this workload tag can be used by itself (in place of a warehouse name), or appended to an existing warehouse name. In either case, Sundeck will intercept the workload tag, and can use it to route queries to the desired warehouse.

For example, if a client typically connects to Snowflake specifying the COMPUTE_WH warehouse, it can connect to Sundeck specifying COMPUTE_WH$SALES or just $SALES as the warehouse. Sundeck will then lookup the SALES workload tag, and if routing is defined for this tag, route to the configured destination warehouse. If the tag is not found, the query will be routed to the original warehouse (COMPUTE_WH in this example), or to the default warehouse if no original warehouse was specified.

For more information on workload routing see workload tagging.

Configuration Syntax

WORKLOAD_ROUTING {
   'workloadToWarehouseMap':[
      {
         'workload'  : <workload-tag>,
         'warehouse' : <warehouse-name>
      }
   ]
}

Arguments

<workload-tag>
String representing workload tag queries were tagged with
<to-warehouse>
Which warehouse to route queries with the tag

Usage Notes

If a non-existent warehouse name is specified for the warehouse property during hook configuration, the configuration will be saved as specified. However, later user queries against the associated workload tag will fail, with an error indicating that the warehouse does not exist.

Examples

CREATE OR REPLACE SUNDECK FLOW "Route queries based on workload tag"
  PRE HOOK route_to_batch_hook
  ALWAYS 
  WORKLOAD_ROUTING {'workloadToWarehouseMap': [{'warehouse': '"Batch"', 'workload': 'sales'}]}
  ENABLED = TRUE;

When you connect to this flow, all the queries tagged with ‘sales’ will be routed to the warehouse “Batch”