Skip to main content

Snowflake Overview

The SNOWFLAKE connector stores MQTT messages in Snowflake, a cloud-native data warehouse. It supports high-volume data ingestion with automatic scaling and powerful SQL analytics.
Snowflake is ideal for large-scale analytics, data lakes, and enterprise reporting. Use it when you need to analyze IoT data alongside other business data in the cloud.

Basic Syntax


Connection Configuration

SNOWFLAKE_CONFIG Parameters

string
required
Snowflake connection string with account, user, and password.
string
Snowflake compute warehouse name. Sent to Snowflake when the session opens.
string
Target database name. Sent to Snowflake when the session opens.
string
Target schema name. Sent to Snowflake when the session opens. If you leave it out, the session uses the schema Snowflake gives your user.
string
Snowflake user role. Sent to Snowflake when the session opens. A role that doesn’t exist, or that your user can’t use, makes the queries fail.
integer
Query timeout in seconds. Default: 60.
integer
Connection pool size. Default: 10. A value of 1 works.
integer
How long a STORE IN row is retried when the connection to Snowflake drops. Default: 300. 0 turns the retry off. See When a row or query fails.
WAREHOUSE, DATABASE, SCHEMA, ROLE, and POOL_SIZE take effect: the broker adds them to the connection it opens, so you can keep them apart from CONNECTION_STRING.
  • The connection string wins. If CONNECTION_STRING already sets the same key (warehouse, db, schema, role, or maxPoolSize, in any letter case), that value is used and the broker logs a warning at route start that names the ignored setting. database= in the connection string counts as db=.
  • No semicolons. A WAREHOUSE, DATABASE, SCHEMA, or ROLE value that contains ; makes adding the route fail with an error that names the setting. A route loaded from a file with such a value doesn’t start.
Never hardcode credentials in production. Use environment variables and encrypted secrets to keep sensitive values out of your connector definitions:
See Environment Variables & Secrets for setup and usage.
The broker log and the error reply of a connector that fails to add mask the password, token, private_key_file, and private_key_pwd values inside a quoted CONNECTION_STRING as ***. The rest of the string, such as the account and user, stays readable.

How placeholders are quoted

The broker places each placeholder in an event QUERY by the quotes around it. A publisher on the source topic can no longer change the SQL by putting SQL in the payload.
Action: Put every placeholder that carries text in single quotes (WHERE status = '{payload}'). Put a placeholder that names a table or column in double quotes (FROM "{topic.2}"). Quoted identifiers are case-sensitive: match the table’s stored case. An unquoted placeholder must be a number, a comma-separated list of numbers, true, false, or null. Anything else, including a bare name such as line_1, refuses the event. The message names the placeholder.
{env.NAME} and {secret.NAME} are placed as written. A value that itself contains {topic} is stored as text and is not expanded again. The same rules on the other SQL engines are in How placeholders are quoted. MongoDB and OpenSearch JSON queries place each value as one JSON value instead (see OpenSearch placeholders).

Snowpipe Streaming

By default, STORE IN runs one SQL INSERT per message, so a warehouse must be running while data flows. Add an optional SNOWPIPE_CONFIG block and STORE IN sends its rows through Snowpipe Streaming instead. The broker batches rows per table, compresses them, and appends them over Snowflake’s REST API. Storing needs no running warehouse. Use it for a steady flow of rows from models. Events (ADD EVENT) still use the SQL connection and the warehouse, and a route without SNOWPIPE_CONFIG behaves as before.

SNOWPIPE_CONFIG parameters

A batch is also cut before it reaches 4 MB. WITH TABLE can be TABLE, SCHEMA.TABLE, or DB.SCHEMA.TABLE; a name given there wins over DATABASE and SCHEMA.

Requirements

  • Key-pair authentication only. CONNECTION_STRING needs account=, user=, and private_key_file= (or private_key=, with private_key_pwd= for an encrypted key). Password sign-in isn’t used for Snowpipe Streaming.
  • Database and schema. They must come from one of the places listed above.
  • Privileges. The role needs INSERT on the table. A named PIPE needs the privileges Snowflake lists for streaming pipes.
  • Columns. Every model field needs a column of the same name. The broker adds a timestamp field when the model has none, as described in Values from STORE IN, and that added field needs no column. A timestamp field the model defines does need one.
A route with an invalid SNOWPIPE_CONFIG is refused when you add it, with the reason. A route loaded from a file with one doesn’t start.

Delivery

  • At least once. A retried batch is sent again, so a row can arrive twice, for example after a timeout. Give the table a key if duplicates matter.
  • Rows are checked before they are sent. Snowflake accepts an append before it reads the rows, then ignores a field with no column and drops a value that doesn’t fit. So the broker reads the table’s columns and checks each row first. A row with a field that has no column, or with text that isn’t a number in a NUMBER or FLOAT column, isn’t sent. It counts as failed, and the log and the route status name the column. Numeric text such as "12" is sent. A column added with ALTER TABLE ... ADD COLUMN is picked up without a restart, at most 30 seconds after a row names it. If the columns can’t be read, for example because the role can’t describe the table, rows are sent unchecked and the broker logs one warning.
  • Rejected rows are reported. After sending, the broker reads the channel status and logs the rows Snowflake rejected while loading them, such as text in a BOOLEAN column. The route status shows them too.
  • Retries. Network errors, HTTP 408, 429, and 5xx are retried with a growing delay up to MAX_RETRY_SECONDS. An expired token is renewed and the batch retried. Any other 4xx counts the batch as failed and logs Snowflake’s error. While a batch is retrying, the route status shows the last error.
  • A full queue drops rows. When QUEUE_CAPACITY rows are waiting, new STORE IN rows are dropped and counted instead of held in memory. The broker logs a warning with the running total, at most once a minute.
  • Rows that can’t be sent, such as a payload that isn’t a JSON object, an invalid table name, or a row over 4 MB, aren’t queued. They’re counted and logged.
  • Stopping. Stopping or removing the route sends queued rows for up to 8 seconds. Rows not acknowledged by then count as failed and are logged with their number.

Writing Data

Store sensor data in Snowflake:
Alternative: STORE IN with Models — Instead of writing EVENT queries, you can bind a model directly to this connector. Every PUBLISH MODEL call automatically inserts a row — no query needed:
See Data Storage Overview for the full STORE IN workflow.

Values from STORE IN

STORE IN sends each value to Snowflake as a bound parameter, never as part of the SQL text. The row is stored exactly as published: backslashes (C:\dados\, a\nb), single and double quotes, $$, accents, and emoji arrive unchanged.
  • Text stays text. A string such as 2026-11-18T10:00:00+01:00 is stored as published and is not reformatted.
  • Numbers and booleans keep their published digits.
  • If the payload has no timestamp field, the broker adds one in ISO-8601 UTC. A timestamp you publish is kept.
Publishing the JSON {"path": "C:\\dados\\"} stores C:\dados\ in the PATH column.
The bound values apply to STORE IN. Values in an event QUERY follow How placeholders are quoted.

When a row or query fails

These rules apply to a connector without SNOWPIPE_CONFIG. Snowpipe Streaming has its own Delivery rules.
  • A row with no data isn’t stored. If every value of a row is empty or null, or the payload is {}, empty, or not JSON, no row is written. The failure is logged with the table name and counted in the route status. The added timestamp doesn’t count as data. A row with at least one value is stored, empty fields included.
  • null is stored as SQL NULL. An empty string "" stays an empty string. A field the model doesn’t have is left out of the INSERT and takes the column default. GET JSON ... AS STRING turns a missing key into "", so leave out the type when the column must be NULL.
  • A row in flight when the connection drops is retried with a growing delay for up to MAX_RETRY_SECONDS (300 by default). While it retries, the route status shows the error. If time runs out or the connector stops, the row is logged as lost and the model’s ON ERROR runs. A statement Snowflake refused, such as an unknown column or a QUERY_TIMEOUT, isn’t retried.
  • A failed event query publishes nothing. When a SELECT fails or exceeds QUERY_TIMEOUT, nothing goes to DESTINATION_TOPIC and the error is logged. [] always means the query ran and returned no rows. Only a lost connection marks the connector Disconnected.
At least once. If the connection drops after Snowflake ran the INSERT but before the reply arrived, the retried row is stored twice. Give the table a key if duplicates matter. Snowflake also reports a failed sign-in, such as a wrong key, as a connection error, so that is retried for MAX_RETRY_SECONDS too. Each retry is logged with Snowflake’s error. Rows wait in memory while they retry, so lower MAX_RETRY_SECONDS on a connector with a high message rate.

Reading Data

EVENTs also support SELECT queries to read data back from the database. Publish a message to the event’s SOURCE_TOPIC, and the query result is published to DESTINATION_TOPIC:
To trigger this query, publish the sensor ID to the source topic:
The query result is published to db/result/latest, where your actions or external clients can consume it.

Timed Polling

EVENTs can also run SELECT queries on a fixed schedule using WITH EVERY:

Table Schema Examples


Connection String Format


Troubleshooting

  • Verify account identifier is correct
  • Check username and password
  • Ensure warehouse exists and is running
  • Verify network allows Snowflake connections
  • Verify ROLE has INSERT permissions
  • Check user has access to WAREHOUSE
  • Ensure user can access DATABASE and SCHEMA
  • Increase QUERY_TIMEOUT value
  • Check warehouse size is adequate
  • Verify warehouse is not suspended

Next Steps

Data Storage Connectors Overview

Compare all storage options.

File Storage Connector

Configure local file storage.
Last modified on December 4, 2026