HOOKS

Your Power Comes From Hooks

Sundeck hooks let you take control of what happens with queries.

Pre-Hooks

Pre-hooks execute before a query. They could work entirely within Sundeck or interact with external systems. Pre-hooks can also reject a query, stopping it from ever hitting Snowflake.

Post-Hooks

Post-hooks execute after a query completes successfully. They are used to act upon the outcome of the query. This could include reviewing the telemetry of a query or other warehouse status.

A Variety of Useful Hooks

Route Pre-Hook

Reroute a query to an alternative warehouse. Route to save money, make queries faster, better distribute load or ensure other workloads have target SLAs.

Reject Pre-Hook

Reject a query with a custom defined error message. Helpful for guiding users (e.g. "don't forget the second join condition") and avoiding anti-patterns ("apply a day filter when reading the giant fact table"). Can also be useful for setting time-of-use rules on certain warehouses or datasets.

SQL Pre-Hook

Execute a Snowflake statement before executing your main query. This can help to setup certain operations. For example, route to an overflow warehouse if the primary warehouse is overloaded. It can also allow you to build advanced granular quota systems such as "don't let a user execute more than $5/day of queries". Your SQL creativity is your limit.

Replace Tables Pre-Hook

Syntax and context aware replacement of one or more tables when they occur. This can be helpful in many situations including when you're running test jobs and want to replace large fact tables with small alternatives.

SQL Post-Hook

Run templated SQL that includes information about the query id of the primary query. Allows you to alert when certain conditions are met or maintain accounting tables for more advanced patterns.

Rewrite Query Pre-Hook

Rewrite your SQL using regular expressions. This allows you to replace common patterns with alternatives or expand simple expressions into complex ones (similar to a macro or alias).

Ready to get started?
Create an account today