Snowflake Trigger

Snowflake Trigger

Certified

Wait for query results on Snowflake and trigger flow

Periodically polls a Snowflake cloud data warehouse by executing a SQL query at the specified interval (default 60 seconds). Triggers a downstream flow execution when the query returns one or more rows. Supports parameterized queries and afterSQL for marking processed rows. Use fetchType to control result handling.

yaml
type: io.kestra.plugin.jdbc.snowflake.Trigger

Wait for a SQL query to return results, and then iterate through rows.

yaml
id: jdbc_trigger
namespace: company.team

tasks:
  - id: each
    type: io.kestra.plugin.core.flow.Loop
    values: "{{ trigger.rows }}"
    tasks:
      - id: return
        type: io.kestra.plugin.core.debug.Return
        format: "{{ fromJson(item.value) }}"

triggers:
  - id: watch
    type: io.kestra.plugin.jdbc.snowflake.Trigger
    interval: "PT5M"
    url: jdbc:snowflake://<account_identifier>.snowflakecomputing.com
    username: "{{ secret('SNOWFLAKE_USERNAME') }}"
    password: "{{ secret('SNOWFLAKE_PASSWORD') }}"
    sql: "SELECT * FROM demo_db.public.customers"
    warehouse: COMPUTE_WH
    fetchType: FETCH
Properties

The SQL query to run

The JDBC URL to connect to the database

Defaultfalse

Specifies whether a trigger is allowed to start a new execution even if a previous run is still in progress.

Specifies the default database to use once connected

The specified database should be an existing database for which the specified default role has privileges. If you need to use a different database after connecting, execute the USE DATABASE command.

Default10000

Number of rows that should be fetched

Gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed for this ResultSet object. If the fetch size specified is zero, the JDBC driver ignores the value and is free to make its own best guess as to what the fetch size should be. Ignored if autoCommit is false.

DefaultFETCH
Possible Values
STOREFETCHFETCH_ONENONE

The way you want to fetch the data

Triggers default to FETCH, which loads all rows into memory and exposes them as {{ trigger.rows }}. A trigger fires only when the query returns at least one row; setting NONE would cause the trigger to never fire. Use FETCH_ONE to expose a single row as {{ trigger.row }}, or STORE to write the rows to internal storage and expose the file URI as {{ trigger.uri }}.

DefaultPT1M
Formatduration

Interval between polling.

The interval between 2 different polls of schedule, this can avoid to overload the remote system with too many calls. For most of the triggers that depend on external systems, a minimal interval must be at least PT30S. See ISO_8601 Durations for more information of available interval values.

Parameters

A map of parameters to bind to the SQL queries. The keys should match the parameter placeholders in the SQL string, e.g., : parameterName.

The database user's password

Private key used for Snowflake key-pair authentication

Kestra supports multiple private key formats for Snowflake key-pair authentication.

You can provide your key in any of the following formats:

  1. PKCS8 DER (base64-encoded, single-line)

  2. PEM PKCS8: -----BEGIN PRIVATE KEY----- ... -----END PRIVATE KEY-----

  3. PEM PKCS1 RSA: -----BEGIN RSA PRIVATE KEY----- ... -----END RSA PRIVATE KEY-----

  4. Multiline or single-line input (Kestra will normalize automatically)

  5. Encrypted PKCS8 (requires providing privateKeyPassword)

Recommended format

Snowflake recommends PKCS8. If your key is in PKCS1 format, Kestra will automatically convert it.

Example: using a PEM PKCS8 key (recommended)

secret('SNOWFLAKE_PRIVATE_KEY') should contain:

-----BEGIN PRIVATE KEY----- MIIEvQIBADANBgkqhkiG9w0BAQEFAASC... ... -----END PRIVATE KEY-----

Example: encrypted private key

privateKey: "{{ secret('SNOWFLAKE_PRIVATE_KEY') }}" privateKeyPassword: "{{ secret('SNOWFLAKE_PRIVATE_KEY_PASSWORD') }}"

Converting a PEM key to unencrypted PKCS8 DER (optional)

openssl pkcs8 -topk8 -nocrypt -inform PEM -outform DER
-in private_key.pem
-out private_key.der

base64 -w 0 private_key.der > private_key.base64

You can then store the content of private_key.base64 as the Kestra secret.

Kestra automatically detects the format and performs the necessary conversions. No manual header stripping or reformatting is required.

Specifies the private key password for key pair authentication and key rotation

Query tag for Snowflake session tracking

Optional string to tag queries executed within the session for monitoring and cost allocation

Specifies the default access control role to use in the Snowflake session initiated by the driver

The specified role should be an existing role that has already been assigned to the specified user for the driver. If the specified role has not already been assigned to the user, the role is not used when the session is initiated by the driver. If you need to use a different role after connecting, execute the USE ROLE command.

Specifies the default schema to use for the specified database once connected

The specified schema should be an existing schema for which the specified default role has privileges. If you need to use a different schema after connecting, execute the USE SCHEMA command.

SubTypestring
Possible Values
CREATEDSUBMITTEDRUNNINGPAUSEDRESTARTEDKILLINGSUCCESSWARNINGFAILEDKILLEDCANCELLEDQUEUEDRETRYINGRETRIEDSKIPPEDBREAKPOINTRESUBMITTED

List of execution states after which a trigger should be stopped (a.k.a. disabled).

The time zone id to use for date/time manipulation. Default value is the worker's default time zone id

The database user

Specifies the virtual warehouse to use once connected

The specified warehouse should be an existing warehouse for which the specified default role has privileges. If you need to use a different warehouse after connecting, execute the USE WAREHOUSE command to set a different warehouse for the session.

Defaulttrue

A condition that determines whether the trigger should run.

A Pebble expression evaluated at trigger time. The trigger fires only when the expression evaluates to a truthy value (true, a non-empty string, a non-zero number). Use this to gate trigger execution on dynamic runtime values such as execution labels, flow variables, or environment conditions.

Size of the stored result file in bytes

Only populated when fetchType is STORE

Formaturi

URI of the column statistics file in internal storage

Only populated when columnStats is true and fetchType is FETCH or STORE; file is stored in ION format

Statement execution duration in milliseconds

Includes reading the result rows

First row of fetched data

Only populated when fetchType is FETCH_ONE

SubTypeobject

List of all fetched rows

Only populated when fetchType is FETCH

Number of rows affected by the statement

Reported by the JDBC driver for INSERT, UPDATE, DELETE and similar statements. Not set when the statement returns a result set or when the driver does not report a count

Number of rows fetched

Only populated when fetchType is FETCH or STORE

Executed SQL statement

Only populated when outputStatement is true. Values of secret() calls are replaced by *** and the text is truncated to 64 KiB

Tables read or written by the statement

Detected from the SQL text, so this is a best effort: CTEs, temporary tables and dialect specific syntax can lower the confidence or be missed. Limited to 50 entries, see tablesTruncated

Definitions
accessstring
Possible Values
READWRITECREATEDROP

How the statement uses the table

One of READ, WRITE, CREATE or DROP.

confidencestring
Possible Values
MEDIUMLOW

How reliable the detection is

MEDIUM when detected from the SQL text, LOW for temporary tables and ambiguous names.

databasestring

Database name

Null when the statement does not qualify the table with a database.

kindstring
Possible Values
TABLEFILEURL

Kind of source

Only set on DuckDB: TABLE, FILE or URL (files read through read_parquet, read_csv, ATTACH and quoted paths).

namestring

Table name

For DuckDB file reads, the file path or URL.

schemastring

Schema name

Null when the statement does not qualify the table with a schema.

Whether the tables list was cut at 50 entries

Formaturi

URI of stored results in internal storage

Only populated when fetchType is STORE; file is stored in internal storage using ION format

Number of SQL warnings raised by the statement

Count of the SQLWarning chain reported by the driver, for example Postgres notices