For the complete documentation index, see llms.txt.
Skip to main content
Version: 8.11 (unreleased)

Snowflake connector

Connect your BPMN process with Snowflake to query and write data with SQL statements.

About this connector​

The Snowflake connector is an outbound protocol connector built on top of the REST connector. It calls the Snowflake SQL API for you, so you select an operation and fill in its parameters instead of building the HTTP request yourself.

For example, use this connector to:

  • Look up customer or risk data with Run SQL statement before a decision in your process.
  • Write a process result back to a Snowflake table.
  • Start a long-running statement asynchronously, read its result later with Get statement status, and stop it with Cancel statement if it takes too long.

Prerequisites​

To use the Snowflake connector, you need:

PrerequisiteDescription
Camunda 8.11 or laterThe connector template requires Camunda 8.11 or later.
Snowflake account URLYour Snowflake account URL, for example https://myorg-myaccount.snowflakecomputing.com. Copy it in Snowsight from Account details.
Snowflake access tokenA Snowflake programmatic access token or an External OAuth access token, stored as a connector secret or in a reusable credential.
Network policyA programmatic access token requires a Snowflake network policy, or an authentication policy with PAT_POLICY = (NETWORK_POLICY_EVALUATION = ENFORCED_NOT_REQUIRED). Otherwise, Snowflake rejects the request with 390432 Network policy is required.
note

Use secrets to avoid exposing your Snowflake access token as plain text. Refer to our documentation on managing secrets to learn more.

Use this connector​

New to using an outbound connector? Learn how to add and use this type of connector, apply element templates, use connector secrets, handle results and errors, and more.

Configuration​

Operation​

Select the operation to run in the Operation dropdown. Each operation is described in operations.

PropertyTypeRequiredDescriptionExample
OperationDropdownYesOne of Run SQL statement, Get statement status, or Cancel statement.Run SQL statement

Authentication​

Choose a reusable Snowflake Authentication credential, or enter the account URL and an access token in the task. The connector sends the token as a bearer token. Snowflake detects if it's a programmatic access token or an External OAuth access token.

PropertyTypeRequiredDescriptionExample
Authentication credentialConfigurationNoA reusable Snowflake Authentication credential, which holds the account URL and the access token. If you select a credential, the Access token and Account URL properties are hidden. See using credentials.
Access tokenStringConditionalA Snowflake programmatic access token or External OAuth access token. Required if you do not select an Authentication credential. Use a secret to avoid exposing the token.{{secrets.SNOWFLAKE_TOKEN}}
Account URLStringConditionalYour Snowflake account URL, starting with https://, without a path, query, or trailing slash. Required if you do not select an Authentication credential.https://myorg-myaccount.snowflakecomputing.com

The Snowflake Authentication credential has the same two properties: Account URL and Access token.

Key-pair authentication with a JSON Web Token (JWT) and the Snowflake OAuth implicit flow are not supported.

Timeout​

PropertyTypeRequiredDescriptionExample
Connection timeout in secondsNumberYesTime to establish the connection. Defaults to 20 seconds. Use 0 for an infinite timeout.20
Read timeout in secondsNumberYesTime to wait for the response. Defaults to 60 seconds. Snowflake waits up to 45 seconds for a result, so keep this value above 45. Use 0 for an infinite timeout.60

Retries​

Retries defaults to 0, because a retried Run SQL statement runs the statement again. Only increase the retries if running a statement more than once is acceptable for your use case.

Operations​

Run SQL statement​

Runs a SQL statement on Snowflake. Uses the Snowflake SQL API operation Submit a SQL statement for execution.

Snowflake waits up to 45 seconds for the result. If the statement takes longer, or if you set Run asynchronously to true, the response is HTTP 202 with a statementHandle and no rows. Get the result with Get statement status.

Input parameters​

PropertyTypeRequiredDescriptionExample
Request IDStringNoA UUID that identifies this request. Leave it empty to let Snowflake assign one. See request ID.
Run asynchronouslyDropdownNoSet to true to return the statement handle at once. Defaults to false.false
Return SQL NULL as nullDropdownNoSet to false to return SQL NULL values as the string "null". Defaults to true.true
Request bodyStringYesThe request as a FEEL context. Requires statement. Set warehouse, database, schema, and role unless the user's defaults apply. See the SQL API reference for all fields, such as timeout and parameters.See below.

For example, where customerId is a process variable:

={
statement: "select * from customers where id = ?",
timeout: 60,
database: "MY_DB",
schema: "PUBLIC",
warehouse: "MY_WH",
bindings: {
"1": {type: "TEXT", value: string(customerId)}
}
}

Pass process variables as bind variables​

To use process variables in a statement, use ? placeholders in the statement and pass the values in bindings. Don't concatenate process variables into the SQL.

Binding values must be strings, also for numbers. Convert them with string(), for example value: string(orderId). Snowflake rejects a JSON number in a binding value with HTTP 422.

Get statement status​

Returns the status and result of a statement. Uses the Snowflake SQL API operation Check the status of the execution of a statement.

While the statement is still running, the response is HTTP 202 with no rows. Check response.status before you read response.body.data, and call the operation again later if the statement hasn't finished.

Snowflake splits large results into partitions and returns one partition per request. resultSetMetaData.partitionInfo in the response lists the partitions.

Input parameters​

PropertyTypeRequiredDescriptionExample
Statement handleStringYesThe statementHandle returned by Run SQL statement.e4ce975e-f7ff-4b5e-b15e-bf25f59371ae
Request IDStringNoA UUID that identifies this request. Leave it empty to let Snowflake assign one. See request ID.
PartitionStringNoThe number of the result partition to return, starting from 0.1

Cancel statement​

Cancels a running statement, for example when it takes longer than your process allows. Uses the Snowflake SQL API operation Cancel the execution of a statement.

Input parameters​

PropertyTypeRequiredDescriptionExample
Statement handleStringYesThe statementHandle returned by Run SQL statement.e4ce975e-f7ff-4b5e-b15e-bf25f59371ae
Request IDStringNoA UUID that identifies this request. Leave it empty to let Snowflake assign one. See request ID.

Request ID​

Snowflake skips a statement it already ran only if the resubmitted request also sets the retry=true parameter. The connector doesn't send retry=true, so reusing a request ID doesn't stop Snowflake from running the statement again. Leave Request ID empty, or use a new ID for every statement you submit, also across tasks and loop iterations.

Output​

The Snowflake connector is built on top of the REST connector, so the response is the HTTP response of the Snowflake SQL API call. In the Result expression, you can use response.status, response.headers, and response.body. Read the REST connector response for details.

The result rows are in response.body.data, a list of rows where each row is a list of column values. FEEL lists start at index 1.

The following result expressions show common mappings:

OperationResult expression
Run SQL statement (synchronous)={customerName: response.body.data[1][1], status: response.status}
Run SQL statement (asynchronous)={handle: response.body.statementHandle, status: response.status}
Get statement status={rows: response.body.data, status: response.status}
Cancel statement={cancelMessage: response.body.message}

Example: run a statement asynchronously​

The following process runs a long statement and reads its result later:

  1. A Run SQL statement task with Run asynchronously set to true and the result expression ={handle: response.body.statementHandle}.
  2. A Get statement status task with Statement handle =handle and the result expression ={rows: response.body.data, status: response.status}.
  3. An exclusive gateway that loops back to the Get statement status task, for example after a timer, while status = 202.

Troubleshooting​

To learn about general error handling in Camunda, see BPMN errors and failing jobs.

Further resources​