> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reelevant.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Snowflake

> Synchronize tables from Snowflake data warehouses into Reelevant

<img src="https://mintcdn.com/reelevant/10tXeCE_biVlzX8s/images/datahub/source-snowflake-v2.png?fit=max&auto=format&n=10tXeCE_biVlzX8s&q=85&s=73e0ff7c8159ab7c9827b93b1f445063" alt="Snowflake source configuration form" width="1280" height="800" data-path="images/datahub/source-snowflake-v2.png" />

## Overview

The Snowflake source synchronizes data from a Snowflake table or view into Reelevant. Use it to bring warehouse data into your personalization workflows.

## Configuration

### Required Fields

| Field       | Description                                                   |
| ----------- | ------------------------------------------------------------- |
| `account`   | Your Snowflake account identifier (e.g. `xy12345.eu-west-1`). |
| `username`  | Snowflake login username.                                     |
| `warehouse` | The Snowflake warehouse to use for running queries.           |
| `database`  | The database name.                                            |
| `schema`    | The schema name.                                              |
| `table`     | The table or view to synchronize.                             |

### Authentication

Snowflake supports two authentication methods:

<Tabs>
  <Tab title="Password">
    Authenticate using a username and password.

    | Field      | Description               |
    | ---------- | ------------------------- |
    | `password` | Snowflake login password. |
  </Tab>

  <Tab title="Key-Pair">
    Authenticate using a key pair (JWT-based authentication). This is the recommended method for production environments.

    | Field        | Description                        |
    | ------------ | ---------------------------------- |
    | `privateKey` | The RSA private key in PEM format. |

    When a private key is provided, Reelevant uses Snowflake's JWT (`SNOWFLAKE_JWT`) authentication, and the password field is ignored.

    <Tip>
      To generate a key pair for Snowflake:

      ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
      openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out rsa_key.p8 -nocrypt
      openssl rsa -in rsa_key.p8 -pubout -out rsa_key.pub
      ```

      Then assign the public key to your Snowflake user:

      ```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
      ALTER USER my_user SET RSA_PUBLIC_KEY='<public_key_content>';
      ```
    </Tip>
  </Tab>
</Tabs>

### Optional Fields

| Field   | Description                                                                                                                               |
| ------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `query` | A custom SQL query to filter or transform the data before import. When provided, the query is executed instead of reading the full table. |

### Custom SQL Queries

When you provide a custom SQL query, Reelevant executes it against Snowflake instead of reading the entire table. This is useful for:

* Filtering rows (e.g. `SELECT * FROM my_table WHERE is_active = TRUE`)
* Selecting specific columns
* Joining multiple tables
* Applying transformations

<Warning>
  The query must be valid Snowflake SQL. Make sure the user has the appropriate role and permissions to access the referenced tables.
</Warning>

## Incremental Sync

Snowflake supports incremental synchronization when used with the **Keep Previous Data** update mode.

| Field             | Description                                                     |
| ----------------- | --------------------------------------------------------------- |
| `timestampColumn` | The column name used to compute the delta since the last fetch. |

When configured, Reelevant appends a `WHERE` clause to your query (or generates one automatically) to only fetch rows where the timestamp column is greater than the last recorded value.

<Info>
  The timestamp column is optional even in Keep Previous Data mode — if your Snowflake view already handles delta logic internally, you can omit it.
</Info>

## Data Type Handling

Snowflake data types are streamed with the following conversions:

| Snowflake Type                          | Behavior                                    |
| --------------------------------------- | ------------------------------------------- |
| `VARCHAR`, `NUMBER`, `FLOAT`, `BOOLEAN` | Passed through as-is.                       |
| `DATE`, `TIMESTAMP_*`, `TIME`           | Fetched as strings (using `fetchAsString`). |
| `VARIANT`, `OBJECT`, `ARRAY`            | Fetched as JSON strings.                    |

## How It Works

1. Reelevant connects to Snowflake using the provided credentials and warehouse.
2. If a custom query is provided, it is executed. Otherwise, `SELECT * FROM <table>` is run.
3. Results are streamed row-by-row for efficient memory usage.
4. Fields are extracted and made available for [mapping](/advanced-guide/datahub/field-mapping).
5. On subsequent syncs, the data is re-read (or incrementally fetched if a timestamp column is configured).

<Warning>
  Ensure the Snowflake user has the appropriate role to access the specified warehouse, database, schema, and table.
</Warning>
