Skip to main content

Snowflake Overview

The SNOWFLAKE route 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

DEFINE ROUTE SensorWarehouse WITH TYPE SNOWFLAKE
    ADD SNOWFLAKE_CONFIG
        WITH CONNECTION_STRING "account=myaccount;user=myuser;password=mypassword"
        WITH WAREHOUSE "COMPUTE_WH"
        WITH DATABASE "IOT_DATA"
        WITH SCHEMA "SENSORS"
    ADD EVENT StoreSensorReading
        WITH SOURCE_TOPIC "sensors/+/reading"
        WITH QUERY "INSERT INTO SENSOR_READINGS (TIMESTAMP, SENSOR_ID, VALUE) VALUES (CURRENT_TIMESTAMP(), '{sensor_id}', PARSE_JSON('{value.json}'))"

Connection Configuration

SNOWFLAKE_CONFIG Parameters

CONNECTION_STRING
string
required
Snowflake connection string with account, user, and password.
WAREHOUSE
string
Snowflake compute warehouse name.
DATABASE
string
Target database name.
SCHEMA
string
Target schema name. Default: PUBLIC.
ROLE
string
Snowflake user role.
QUERY_TIMEOUT
integer
Query timeout in seconds. Default: 60.
POOL_SIZE
integer
Connection pool size. Default: 10.

Complete Examples

Store sensor data in Snowflake:
DEFINE ROUTE SensorWarehouse WITH TYPE SNOWFLAKE
    ADD SNOWFLAKE_CONFIG
        WITH CONNECTION_STRING "account=myaccount;user=iot_user;password=secure_password"
        WITH WAREHOUSE "IOT_WH"
        WITH DATABASE "IOT_DATA"
        WITH SCHEMA "SENSORS"
        WITH ROLE "IOT_WRITER"
    ADD EVENT StoreReading
        WITH SOURCE_TOPIC "sensors/+/reading"
        WITH DESTINATION_TOPIC "snowflake/status"
        WITH QUERY "INSERT INTO SENSOR_READINGS (TIMESTAMP, SENSOR_ID, VALUE) VALUES (CURRENT_TIMESTAMP(), '{sensor_id}', PARSE_JSON('{value.json}'))"

Table Schema Examples

-- Sensor readings with VARIANT for JSON
CREATE TABLE SENSOR_READINGS (
    ID NUMBER AUTOINCREMENT,
    TIMESTAMP TIMESTAMP_NTZ DEFAULT CURRENT_TIMESTAMP(),
    SENSOR_ID VARCHAR(50),
    VALUE VARIANT
);

-- Event log
CREATE TABLE EVENT_LOG (
    ID NUMBER AUTOINCREMENT,
    TIMESTAMP TIMESTAMP_NTZ DEFAULT CURRENT_TIMESTAMP(),
    TOPIC VARCHAR(255),
    PAYLOAD VARIANT
);

Connection String Format

account=<account_identifier>;user=<username>;password=<password>
ComponentDescription
accountSnowflake account identifier (e.g., xy12345.us-east-1)
userSnowflake username
passwordUser password

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