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

SQL

The SQL Pre-hook allows one to run pre-defined SQL against Snowflake before the user’s query is submitted

Configuration Syntax

  {
      'queryText': <query>,
      'errorBehavior': <onError>
  }

Arguments

<query>
The text of the SQL to run prior to the user’s query
<onError>
Either REJECT or BYPASS to determine the behavior if an error occurs while running the pre-hook SQL. If REJECT, the user’s query will not run if an error occurs, while BYPASS will ignore the error and continue with other pre-hooks followed by the user’s query.

Examples

CREATE SUNDECK FLOW NEWBIE_FLOW
    PRE HOOK TRACK_USAGE
    IF role = newbie THEN
    SQL {
      'sqlText': 'SELECT newbie_query_tracking.nextval',
      'errorBehavior' : 'BYPASS'
    }
;

In this case, the newbie_query_tracking sequence will be incremented if the current user is in the newbie role. In this case, the sequence would already have to have been created or a runtime error would occur, in which case the user’s query would still run since our error behavior is set to BYPASS.