Skip to contentManaged Kafka is live: Apache Kafka on AWS for half the cost of MSK

Sources

Snowflake source: setup and configuration

Configure Snowflake as a source in Artie with key-pair authentication, a read-only service user, and change tracking on each table you replicate.

Prerequisites

  • Your Snowflake account URL or account identifier
  • A role that can create users, roles and warehouses (SECURITYADMIN and SYSADMIN)
  • Ownership of each table you want to replicate, to turn on change tracking
  • A primary key on each table, either declared in Snowflake or set as a merge key in Artie

Prepare Snowflake

Do these steps before you connect Snowflake in Artie. The Prepare Snowflake step of the pipeline setup shows the same scripts.

  1. Generate a key pair

    Snowflake sources sign in with key-pair authentication only. Generate an RSA key pair:

    Bash
    openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out rsa_key.p8 -nocrypt
    openssl rsa -in rsa_key.p8 -pubout -out rsa_key.pub

    rsa_key.pub goes on the Snowflake user in the next step. You paste rsa_key.p8 into Artie when you connect the source.

  2. Create a role, service user and warehouse

    Replace the RSA_PUBLIC_KEY value with the contents of rsa_key.pub, without the BEGIN and END lines.

    setup.sql
    USE ROLE SECURITYADMIN;
    CREATE ROLE IF NOT EXISTS ARTIE_READER;
    CREATE USER IF NOT EXISTS ARTIE_READER
      TYPE = SERVICE
      RSA_PUBLIC_KEY = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA...'
      DEFAULT_ROLE = ARTIE_READER
      DEFAULT_WAREHOUSE = ARTIE_WH;
    GRANT ROLE ARTIE_READER TO USER ARTIE_READER;
    
    USE ROLE SYSADMIN;
    CREATE WAREHOUSE IF NOT EXISTS ARTIE_WH
      WAREHOUSE_SIZE = XSMALL AUTO_SUSPEND = 60 AUTO_RESUME = TRUE INITIALLY_SUSPENDED = TRUE;
  3. Grant read access

    Grant the role access to the warehouse and to each table you want to replicate:

    grants.sql
    GRANT USAGE ON WAREHOUSE ARTIE_WH TO ROLE ARTIE_READER;
    GRANT USAGE ON DATABASE ANALYTICS TO ROLE ARTIE_READER;
    GRANT USAGE ON SCHEMA ANALYTICS.PUBLIC TO ROLE ARTIE_READER;
    GRANT SELECT ON TABLE ANALYTICS.PUBLIC.ORDERS TO ROLE ARTIE_READER;
  4. Turn on change tracking

    As the table owner, turn on change tracking for each table:

    SQL
    ALTER TABLE ANALYTICS.PUBLIC.ORDERS SET CHANGE_TRACKING = TRUE;

    Change tracking only records changes made after it’s turned on. Artie snapshots each table first, so nothing before that is missed.

    If change tracking is off on any table, the pipeline stops with change tracking is not enabled and the ALTER TABLE command to run.

  5. Check the table's retention

    Artie reads changes from the table’s Time Travel history, so the table needs a DATA_RETENTION_TIME_IN_DAYS of at least 1. That’s Snowflake’s default.

    A table with a retention of 0 stops the pipeline at start, and the error gives the command that sets it to 1.

    If the pipeline is down longer than the table’s retention, it stops with change history is no longer available and the table needs a backfill. On Enterprise Edition, a longer retention gives you more time:

    SQL
    ALTER TABLE ANALYTICS.PUBLIC.ORDERS SET DATA_RETENTION_TIME_IN_DAYS = 7;

Connect Snowflake in Artie

These steps cover the source part of the pipeline setup. Snowflake has no network access step.

  1. Choose the source

    On Choose your source, select Snowflake, then select Continue.

  2. Prepare Snowflake

    On Prepare Snowflake, run the scripts from Prepare Snowflake, then select Continue.

  3. Enter the connection settings

    On Connect Snowflake, fill in the connection settings.

  4. Verify the source

    Select Verify source. The step shows Source verified.

  5. Continue

    Select Continue to choose the tables to replicate.

To check the source later, select Verify later.

When you pick a Snowflake connector that other pipelines use, the setup skips the preparation step. Edit that connector’s credentials in Settings → Connectors.

Connection settings

Every field is required. Snowflake sources have no password option.

FieldValue
Snowflake URL or account identifierPaste the URL from your Snowflake browser tab, or enter the account identifier, for example myorg-account123. For a legacy account URL, select Use a legacy account URL instead.
UsernameThe service user, ARTIE_READER.
Private keyThe contents of rsa_key.p8: an unencrypted PKCS #8 RSA key, including its BEGIN and END lines.
Warehouse nameThe warehouse from setup.sql, ARTIE_WH. The source form lists existing warehouses and doesn’t create one.
Role nameThe role from setup.sql, ARTIE_READER. Artie preselects the user’s default role.
Database nameThe database you replicate, for example ANALYTICS.

Advanced options

Advanced options on Connect Snowflake holds two optional settings.

SettingDefaultWhat it does
LabelSnowflakeTells this connector apart when you reuse it.
Message compressionNone (default)GZIP compresses the messages Artie writes to Kafka. See Message compression.

Replication behavior

These sections describe how Artie reads a Snowflake source once the pipeline runs.

How does Artie read changes from Snowflake?

Artie snapshots each table once, then reads its changes with Snowflake’s CHANGES clause:

  • Artie reads each table’s changes since the last read, then waits 5 minutes before the next read.
  • Each read ends 10 seconds behind Snowflake’s clock, so a transaction that’s still committing isn’t missed.
  • After an outage, Artie catches up in windows of up to one hour and saves its place after each one.
  • Up to 4 tables are read at a time.

Warehouse cost

Each read runs a query on your warehouse, even when a table hasn’t changed. A small warehouse with AUTO_SUSPEND = 60, as in setup.sql, keeps that cost low.

Schema changes

When a column is added or dropped, Artie reads the table’s columns again and keeps syncing. A change window can still miss the new columns, for example when it ends before a column was added. Then the pipeline stops with columns changed and the table’s name. Schema evolution covers how Artie applies schema changes in the destination.

Primary keys

Snowflake doesn’t enforce primary keys, so Artie uses the key declared on the table. If a table has no declared key, or the declared key isn’t unique, choose the key columns yourself:

  • In the pipeline setup, set the table’s Merge key. Tables with no declared key prompt for one in Set merge keys.
  • On an existing pipeline, turn on Override primary keys in the table’s settings.

A row whose primary key is NULL stops the sync with an error that names the column. Choose key columns that are never NULL.

Supported data types

Artie reads these Snowflake types:

  • NUMBER, DECIMAL, NUMERIC, DECFLOAT
  • FLOAT, DOUBLE, REAL
  • VARCHAR, CHAR, STRING, TEXT
  • BINARY, VARBINARY
  • BOOLEAN
  • UUID
  • DATE, TIME, DATETIME, TIMESTAMP_NTZ, TIMESTAMP_LTZ, TIMESTAMP_TZ
  • VARIANT, OBJECT, ARRAY, MAP, VECTOR and FILE, as JSON
  • GEOGRAPHY and GEOMETRY, as EWKB with the SRID

Artie reads NUMBER and DECFLOAT values as Snowflake’s exact text, so values with more than 15 significant digits keep full precision.

A column of any other type, for example IPADDRESS, stops the pipeline at start with unsupported type and the column’s name. To replicate the table, exclude the column. If the column is part of the primary key, choose different key columns.

Recreated tables and dbt models

Incremental dbt models work as-is. dbt table models recreate the table with CREATE OR REPLACE on every run, which drops the table’s change history. The new table starts without change tracking.

On its next read, Artie stops the whole pipeline, not only that table, with change tracking is not enabled. Turning change tracking back on doesn’t recover it, because the recreated table has no history from before the run. The pipeline then stops with change history is no longer available. Use an incremental materialization for tables you replicate with Artie.

Next steps

Was this page helpful?