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

CREATE SUNDECK FLOW

Creates a or replaces a Flow. Flows are unique endpoints that can be used to reference your Snowflake accounts. A flow contains zero or more hooks, which are executed in the order that they are declared. When a flow is created, it is assigned a unique hostname. This hostname is used to address the flow until the flow is dropped. To understand more about flows, read the flows overview

See also:
ALTER SUNDECK FLOW, SHOW SUNDECK FLOWS, DESCRIBE SUNDECK FLOW, DROP SUNDECK FLOW

Syntax

CREATE [OR REPLACE] SUNDECK FLOW <name>
    [ COMMENT <comment> ]
    <[hook-definition> [, <hook-definition>]* ]
    [DEFAULT_WAREHOUSE = <warehouse_name>]
;

Where:

<hook-definition> ::=
    [ PRE | POST ] HOOK <hook_instance_name>
    { IF <condition_expression> THEN | ALWAYS }
    <hook_instance_type_name> <hook_configuration>
    [ ENABLED = { TRUE | FALSE } ]
    

Parameters

<name>
Specifies the identifier for the flow to create. If the identifier contains spaces, special characters, or mixed-case characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive (e.g. “My Object”).
<comment>
Specifies a comment for the flow, which can be used to describe the flow in detail. Comment is a snowflake string literal, it should be enclosed in single quotes.
<hook-definition>
An hook instance definition (see hook parameters below).
<warehouse_name>
The default warehouse to route queries to this warehouse to.

hook Parameters

<hook_instance_name>
The identifier you want to give the hook instance. Should describe the purpose of this hook for later reference. If the identifier contains spaces, special characters, or mixed-case characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive (e.g. “My Object”).
<condition_expression>
The condition expression is a boolean statement that includes one or more conditions along with parentheses, AND, OR, not, etc. Review the conditions reference for a complete overview.
<hook_instance_type_name>
The type of hook to create. Currently available built-in system Pre-hooks and built-in system Post-hooks
<hook_configuration>
A Snowflake object literal that describes the configuration for the provided hook.
ENABLED = { TRUE | FALSE }
Specifies whether hook will be actived or not. If omitted, hook is activated.

Usage Notes

  • Flow and warehouse identifier follow Snowflake Identifier rules.
  • When you use CREATE or REPLACE with an existing flow, the unique id of the flow is left unchanged. This allows you to update flows without an ALTER statement.
  • Snowflake variant literal is similar but not the same as JSON. Snowflake variant literals are expressed using brackets and single quotes. Additionally, string literals can be expressed using either single quote literals ' or $$ literals.

Examples

CREATE SUNDECK FLOW "My empty flow";
CREATE SUNDECK FLOW EXEC_DASHBOARDS
    PRE HOOK "Check For Things"
      IF SQL_CONTAINS('hello') 
      THEN ROUTE {'toWarehouse':'PRIVATE'}
;
CREATE SUNDECK FLOW REJECT_ALL
    COMMENT 'this flow rejects all queries'
    PRE HOOK "Reject Everything" 
      ALWAYS REJECT {'rejectMessage': 'this flow rejects all queries'}
    ENABLED = TRUE
    DEFAULT_WAREHOUSE = "ALT1"
;