The snowflake> operator executes SQL statements on Snowflake.
_export:
snowflake:
account_identifier: MYORGANIZATION-MYACCOUNT
user: MY_USER
database: MY_DATABASE
+statement_from_file:
snowflake>: my_statement.sql
+statement_with_bindings:
snowflake>:
statement: select * from my_table where column1 = :my_string and column2 = :my_number
bindings:
my_string: some_value
my_number: 123
+multiple_statements:
snowflake>:
statement: |
insert into my_table (column1, column2) values ('my_value', 100);
update my_table set column2 = column2 + 1 where column1 = 'my_value';
+store_results:
snowflake>:
statement: select count(*) as "total_count" from my_table
store_last_results: true
+print_total_count:
echo>: The total count is ${snowflake.last_results.total_count}The operator supports two authentication methods: key pair authentication and programmatic access token authentication.
You must configure secrets for one of these authentication methods based on the authentication_method parameter (defaults to key_pair).
snowflake.private_key: STRING
Required when using key pair authentication. The private key in PEM format. Only RSA keys are supported.
snowflake.private_key_password: STRING
Optional. The password for the private key if it is encrypted.
snowflake.programmatic_access_token: STRING
Required when using programmatic access token authentication. The programmatic access token.
snowflake>: FILE
Path to a SQL file containing the SQL statement(s) to execute. The file can contain
${...}syntax to embed variables.Examples:
snowflake>: my_statement.sqlstatement: STRING
The SQL statement(s) to execute. Use this parameter to specify the SQL statements inline instead of using a file. This parameter can contain
${...}syntax to embed variables.Examples:
statement: select current_version()statement: | insert into my_table (column1, column2) values ('my_value', 100); update my_table set column2 = column2 + 1 where column1 = 'my_value';account_identifier: STRING
Required. The Snowflake account identifier.
Examples:
account_identifier: MYORGANIZATION-MYACCOUNTauthentication_method: key_pair | programmatic_access_token
The authentication method to use. Default:
key_pair.Examples:
authentication_method: key_pairauthentication_method: programmatic_access_tokenuser: STRING
Required when using key pair authentication. The Snowflake user to authenticate as.
Examples:
user: MY_USERdatabase: STRING
The Snowflake database in which to execute the SQL statement.
Examples:
database: MY_DATABASEschema: STRING
The Snowflake schema in which to execute the SQL statement.
Examples:
schema: MY_SCHEMAwarehouse: STRING
The Snowflake warehouse to use for executing the SQL statement.
Examples:
warehouse: MY_WAREHOUSErole: STRING
The Snowflake role to use when executing the SQL statement.
Examples:
role: MY_ROLEbindings: ARRAY or OBJECT
The values for bind variables in the SQL statement.
For positional bind variables (
?), provide an array of values in the order they appear in the SQL statement. For named bind variables (:name), provide an object with variable names as keys (without the colon prefix) and the corresponding values.Note: Bind variables are not supported when executing multiple SQL statements.
Examples:
bindings: - some_value - 123bindings: my_string: some_value my_number: 123query_tag: STRING
The query tag to associate with the SQL statement.
Examples:
query_tag: my-query-tagtimezone: STRING
The timezone to use when executing the SQL statement.
Examples:
timezone: America/Los_Angelesstore_last_results: BOOLEAN
Whether to store the results of the SQL statement in the
snowflake.last_resultsoutput parameter. Default:false.When set to
true, the first row of the result set is stored in thesnowflake.last_resultsoutput parameter as an object, with column names as keys.When multiple statements are executed, only the results of the last statement are stored.
Date, time, and timestamp values are formatted using the
YYYY-MM-DD,HH24:MI:SS, andYYYY-MM-DD HH24:MI:SS.FF3[ TZHTZM]formats, respectively. Binary values are encoded as hexadecimal strings.Examples:
store_last_results: true_timeout: DURATION
The maximum time to wait for the task to complete before timing out. If the timeout is reached, statement execution will be canceled.
Examples:
_timeout: 30m
snowflake.last_results
The first row of the statement execution results as an object. This is only set when
store_last_results: trueis specified.For example, if the statement
select count(*) as "total_count" from my_tablereturns a single row with a column namedtotal_count, you can access it as${snowflake.last_results.total_count}.snowflake.last_statement.handle
The handle of the executed statement. If multiple statements are executed, the handle of the last statement is stored.
Example:
01bf6433-0106-8cd2-0070-6287007a936asnowflake.last_statement.num_records
The number of rows returned by the executed statement. If multiple statements are executed, the number of rows returned by the last statement is stored.
Example:
1
The operator uses the Snowflake SQL API, which has certain limitations:
See the official documentation for more details on the limitations of the Snowflake SQL API.