---
title: Connect Snowflake for Warehouse-Native Experiment Analysis
description: >-
  Connect a Snowflake service account to enable warehouse-native experiment
  analysis.
breadcrumbs: >-
  Docs > Experiments > Experiments Guides > Connect Snowflake for
  Warehouse-Native Experiment Analysis
---

# Connect Snowflake for Warehouse-Native Experiment Analysis

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com

{% alert level="danger" %}
This product is not supported for your selected [Datadog site](https://docs.datadoghq.com/getting_started/site). ().
{% /alert %}

{% /callout %}

## Overview{% #overview %}

Warehouse-native experiment analysis lets you run statistical computations directly in your data warehouse.

To set this up for Snowflake, connect a Snowflake service account to Datadog and configure your experiment settings. This guide covers:

- Preparing a Snowflake service account
- Connecting it to Datadog
- Configuring experiment settings

## Step 1: Prepare the Snowflake service account{% #step-1-prepare-the-snowflake-service-account %}

The examples in this guide use `datadog_experiments_user` and `datadog_experiments_role` as the service account's user and role. Replace these with your own values.

### Create a dedicated service user and role in Snowflake{% #create-a-dedicated-service-user-and-role-in-snowflake %}

1. Use the [Snowflake documentation](https://docs.snowflake.com/en/user-guide/key-pair-auth) to create a public-private key pair for enhanced authentication. Datadog only supports unencrypted private keys.
1. Run the following commands in Snowflake to create the user and role in the service account. Replace `<public_key>` with the public key you generated in the previous step.

```sql
USE ROLE ACCOUNTADMIN;
CREATE ROLE IF NOT EXISTS datadog_experiments_role;
CREATE USER IF NOT EXISTS datadog_experiments_user
    RSA_PUBLIC_KEY = '<public_key>';
GRANT ROLE datadog_experiments_role TO USER datadog_experiments_user;
ALTER USER datadog_experiments_user SET DEFAULT_ROLE = datadog_experiments_role;
```

### Grant privileges to the role{% #grant-privileges-to-the-role %}

1. Identify the tables in Snowflake from which you intend to create metrics.
1. Run the following commands to grant read privileges to the new role, replacing `<database>`, `<schema>`, and `<table>` with their appropriate values. Run both `GRANT USAGE` commands, then run the `GRANT SELECT` option or options that match your access needs.

```sql
GRANT USAGE ON DATABASE <database> TO ROLE datadog_experiments_role;
GRANT USAGE ON SCHEMA <database>.<schema> TO ROLE datadog_experiments_role;

-- Option 1: Give read access to a single table
GRANT SELECT ON TABLE <database>.<schema>.<table> TO ROLE datadog_experiments_role;

-- Option 2: Give read access to all existing tables in the schema
GRANT SELECT ON ALL TABLES IN SCHEMA <database>.<schema> TO ROLE datadog_experiments_role;

-- Option 3: Give read access to all future tables in the schema
GRANT SELECT ON FUTURE TABLES IN SCHEMA <database>.<schema> TO ROLE datadog_experiments_role;
```

### Grant the role access to the output schema{% #grant-the-role-access-to-the-output-schema %}

Datadog writes experiment exposure logs and intermediate metric results to tables in a dedicated output schema. Run the following commands to create the schema and grant the role full access. Replace `<database>` with the appropriate value.

```sql
CREATE SCHEMA IF NOT EXISTS <database>.datadog_experiments_output;
GRANT ALL ON SCHEMA <database>.datadog_experiments_output TO ROLE datadog_experiments_role;
GRANT ALL PRIVILEGES ON FUTURE TABLES IN SCHEMA <database>.datadog_experiments_output TO ROLE datadog_experiments_role;
```

### Create a dedicated warehouse for Datadog Experiments (optional){% #create-a-dedicated-warehouse-for-datadog-experiments-optional %}

{% alert level="info" %}
The role you created must have access to at least one warehouse to compute results. You must enter the warehouse name when configuring experiment settings in Step 3.
{% /alert %}

Creating a dedicated warehouse for Datadog Experiments is optional. Run the following commands to create one. Replace `<wh_size>` with the appropriate value.

```sql
CREATE WAREHOUSE IF NOT EXISTS datadog_experiments_wh
    WAREHOUSE_SIZE = <wh_size>
    AUTO_SUSPEND = 300
    INITIALLY_SUSPENDED = true;
GRANT ALL PRIVILEGES ON WAREHOUSE datadog_experiments_wh TO ROLE datadog_experiments_role;
```

## Step 2: Connect Snowflake to Datadog{% #step-2-connect-snowflake-to-datadog %}

To connect your Snowflake account to Datadog for warehouse-native experiment analysis:

1. Navigate to [Datadog's integrations page](https://app.datadoghq.com/integrations) and search for **Snowflake**.
1. Click the **Snowflake** tile to open its modal.
1. Select the **Configure** tab and click **Add Snowflake Account**.
1. Add your **Account URL**. To find your account URL, see the [Snowflake guide](https://docs.snowflake.com/en/user-guide/organizations-connect).
1. Toggle off all resources (these are not needed for experiment analysis).
1. Enter the Snowflake **User Name** you created in Step 1 (for example, `datadog_experiments_user`).
1. Scroll to the **Configure a key pair authentication** section and upload your unencrypted **private key**.
1. Click **Save**.

{% alert level="info" %}
The grants in the **Recommended Warehouse Settings** section of the Snowflake integration tile are not needed for warehouse-native experiment analysis. The privileges granted in Step 1 are sufficient.If you plan to use other warehouse observability functionality in Datadog, see [Datadog's Snowflake integration documentation](https://docs.datadoghq.com/integrations/snowflake-web/) to determine which resources to enable.
{% /alert %}

{% image
   source="https://docs.dd-static.net/images/product_analytics/experiment/guide/snowflake_main_integration.6732b76797eee7fffd863012a603bffd.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/product_analytics/experiment/guide/snowflake_main_integration.6732b76797eee7fffd863012a603bffd.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="The Snowflake integration tile in Datadog showing the Configure tab with the Add a new Snowflake account form, including an Account URL field and resource toggles for Metrics and Logs." /%}

## Step 3: Configure experiment settings{% #step-3-configure-experiment-settings %}

{% alert level="info" %}
Datadog supports one warehouse connection per organization. Connecting Snowflake replaces any existing warehouse connection (for example, Redshift).
{% /alert %}

After you set up your Snowflake integration, configure the experiment settings in [Datadog Product Analytics](https://app.datadoghq.com/product-analytics):

1. In the left navigation, hover over **Settings**, then click **Experiments**.
1. Select the **Warehouse Connections** tab.
1. Click **Connect a data warehouse**. If you already have a warehouse connected, click **Edit** instead.
1. Select the **Snowflake** tile.
1. Enter the **Account**, **Role**, **Warehouse**, **Database**, and **Schema** you configured in Step 1. If your database and schema do not appear in the dropdown, enter them manually to add them to the list.
1. Click **Save**.

{% image
   source="https://docs.dd-static.net/images/product_analytics/experiment/guide/snowflake_experiment_setup.513728767a9be9ef74574c5af29a07e7.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/product_analytics/experiment/guide/snowflake_experiment_setup.513728767a9be9ef74574c5af29a07e7.png?auto=format&fit=max&w=850&dpr=2 2x"
   alt="The Edit Data Warehouse modal with Snowflake selected, showing two sections: Select Snowflake Account with fields for Account, Role, and Warehouse, and Select Database and Schema with fields for Database and Schema." /%}

After you save your warehouse connection, create experiment metrics using your Snowflake data. See [Create Experiment Metrics](https://docs.datadoghq.com/experiments/defining_metrics).

## Further reading{% #further-reading %}

- [Defining metrics in Datadog Experiments](https://docs.datadoghq.com/experiments/defining_metrics)
- [How to bridge speed and quality in experiments through unified data](https://www.datadoghq.com/blog/experimental-data-datadog/)
