You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/connections/storage/catalog/snowflake/index.md
+67-53Lines changed: 67 additions & 53 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,22 +7,36 @@ redirect_from:
7
7
8
8
{% include content/warehouse-ip.html %}
9
9
10
-
[Snowflake](https://docs.snowflake.net/manuals/index.html) is a data warehouse built for the cloud. Snowflake delivers performance, simplicity, concurrency and affordability.
10
+
[Snowflake](https://docs.snowflake.net/manuals/index.html){:target="_blank"} is a data warehouse, built for the cloud, that delivers performance, simplicity, concurrency and affordability.
11
11
12
-
## Getting Started
12
+
## Getting started
13
13
14
-
There are six steps to get started using Snowflake with Segment. Make sure that you are running the commands in each step while logged in as an `ACCOUNTADMIN`, or an account that has `MANAGE GRANTS`. While Segment uses predefined user (`SEGMENT_USER`), role (`SEGMENT`), warehouse (`SEGMENT_WAREHOUSE`) and database (`SEGMENT_EVENTS`) names, you can use any names you like.
14
+
There are six steps to get started using Snowflake with Segment.
15
15
16
-
1. Create Virtual Warehouse
17
-
2. Create Database
18
-
3. Create Role for Segment
19
-
4. Create User for Segment
20
-
5. Test the User and Credentials
21
-
6. Connect Snowflake to Segment
16
+
1.[Create a virtual warehouse](#step-1-create-a-virtual-warehouse)
17
+
2.[Create a database](#step-2-create-database)
18
+
3.[Create a role for Segment](#step-3-create-role-for-segment)
19
+
4.[Create a user for Segment](#step-4-create-user-for-segment)
20
+
5.[Test the user and credentials](#step-5-test-the-user-and-credentials)
21
+
6.[Connect Snowflake to Segment](#step-6-connect-snowflake-to-segment)
22
22
23
-
### Create Virtual Warehouse
23
+
### Prerequisites
24
24
25
-
The Segment Snowflake destination requires a Snowflake [virtual warehouse](https://docs.snowflake.net/manuals/user-guide/warehouses.html){:target="_blank"} to load data in to. To avoid conflicts with other regular operations in your cluster, Segment recommends that you create a new warehouse just for Segment loads, but this is not mandatory. An X-Small warehouse works for most customers when starting.
25
+
To set up the Snowflake destination in Segment, you must have, at a minimum, the following [Snowflake privileges](https://docs.snowflake.com/en/user-guide/security-access-control-overview#label-access-control-overview-privileges){:target="_blank"}:
26
+
-[CREATE WAREHOUSE](https://docs.snowflake.com/en/sql-reference/sql/create-warehouse#access-control-requirements){:target="_blank"}: Used to create a Segment-specific virtual warehouses
27
+
-[CREATE DATABASE](https://docs.snowflake.com/en/sql-reference/sql/create-database#access-control-requirements){:target="_blank"}: Used to create a Segment-specific database
28
+
-[CREATE ROLE](https://docs.snowflake.com/en/sql-reference/sql/create-role#access-control-requirements){:target="_blank"}: Used to create the role that the Segment user assumes in your Snowflake instance
29
+
-[CREATE USER](https://docs.snowflake.com/en/sql-reference/sql/create-user#access-control-requirements){:target="_blank"}: Used to create the Segment user in your Snowflake instance
30
+
31
+
To set up the Snowflake storage destination in Segment, you must have either a [role in the Segment app](/docs/segment-app/iam/roles/) of _Workspace Owner_ or, for Business Tier users, _Warehouse Destination Admin_.
32
+
33
+
### Step 1: Create a virtual warehouse
34
+
35
+
Segment's Snowflake destination requires you to first create a Snowflake [virtual warehouse](https://docs.snowflake.com/en/user-guide/warehouses){:target="_blank"}.
36
+
37
+
To avoid conflicts with other operations in your cluster, Segment recommends that you create a new warehouse just for Segment loads, but this is not mandatory. An X-Small warehouse works for most Segment customers when they first create their Snowflake destination.
38
+
39
+
To create a new virtual warehouse, navigate to **Warehouses** > **Create** in Snowflake's Classic Console or execute the following SQL command:
Make sure `AUTO_SUSPEND` is set to ~10 minutes in the UI (or 600 if using SQL) and `AUTO_RESUME` is enabled, to avoid extra costs.
49
+
> success ""
50
+
> Set `AUTO_SUSPEND` to ~10 minutes in the UI (or 600 if using SQL) and enable `AUTO_RESUME` to avoid extra costs, as Snowflake uses [per-second billing](https://docs.snowflake.com/en/user-guide/warehouses-considerations#automating-warehouse-suspension){:target="_blank"}.
51
+
52
+
### Step 2: Create Database
36
53
37
-
### Create Database
54
+
Segment recommends creating a new database just for Segment information, as the Segment Snowflake destination creates its own schemas and tables and could create name conflicts with your existing data.
38
55
39
-
The Segment Snowflake destination creates its own schemas and tables, so it's recommended to create a new database for this purpose to avoid name conflicts with existing data.
56
+
To create a new database, execute the following SQL command:
40
57
41
58
```sql
42
59
CREATEDATABASE "SEGMENT_EVENTS";
43
60
```
44
61
45
-
### Create Role for Segment
46
-
47
-
You need to run these commands rather than creating a role with the "Create Role" dialog in the UI.
62
+
### Step 3: Create role for Segment
48
63
49
-
This role will be attached to Segment's user and it gives just enough permissions for loading data in your database. Segment recommends that you not reuse this role for other operations.
64
+
You need to run these SQL commands rather than creating a role with the "Create Role" dialog in the Classic Console UI.
50
65
51
-
1. Click on to Worksheets;
66
+
This role gives Segment just enough permission to load data into your database. Segment recommends that you don't reuse this role for other operations.
67
+
1. Click on **Worksheets**
52
68
2. Select SEGMENT_EVENTS under database objects
53
-
3. Change role to ACCOUNTADMIN
54
-
55
-
4. Create a new role using the following command:
69
+
3. Change role to `ACCOUNTADMIN`
70
+
4. Create a new role by executing the following command:
56
71
```sql
57
72
CREATE ROLE "SEGMENT";
58
73
```
59
74
60
-
5. Grant access to the virtual warehouse:
75
+
5. Grant access to the virtual warehouse by executing the following SQL command:
61
76
```sql
62
77
GRANT USAGE ON WAREHOUSE "SEGMENT_WAREHOUSE" TO ROLE "SEGMENT";
63
78
```
64
79
65
-
6. Grant access to the database:
80
+
6. Grant access to the database by executing the following SQL command:
66
81
```sql
67
82
GRANT USAGE ON DATABASE "SEGMENT_EVENTS" TO ROLE "SEGMENT";
68
83
GRANT CREATE SCHEMA ON DATABASE "SEGMENT_EVENTS" TO ROLE "SEGMENT";
69
84
```
70
85
71
-
### Create User for Segment
86
+
### Step 4: Create user for Segment
72
87
73
-
Finally, you need to create the user that will be connected to Segment. Be sure to use a strong, unique password.
88
+
You need to create the user that Segment uses to connect to your warehouse. Be sure to use a strong, unique password.
74
89
75
90
```sql
76
91
CREATEUSER "SEGMENT_USER"
@@ -80,28 +95,28 @@ CREATE USER "SEGMENT_USER"
80
95
GRANT ROLE "SEGMENT" TO USER "SEGMENT_USER";
81
96
```
82
97
83
-
### Test the User and Credentials
98
+
### Step 5: Test the user and credentials
84
99
85
100
Before you continue, test and validate the new user and credentials. When you can run the following commands successfully, you can connect Snowflake to Segment.
86
101
87
-
Segment uses [snowsql](https://docs.snowflake.net/manuals/user-guide/snowsql.html){:target="_blank"} to run these verification steps.
88
-
To install and verify your accounts:
102
+
Segment uses [SnowSQL](https://docs.snowflake.com/en/user-guide/snowsql){:target="_blank"} to run these verification steps.
3. Once the installation is complete, run the following command, replacing "account" and "user" with your Snowflake Account and username:
107
+
3. Once the installation is complete, run the following command, replacing "account" and "user" with your Snowflake Account ID and username:
93
108
94
109
```
95
110
snowsql -a <account> -u <user>
96
111
```
97
112
98
113
For accounts outside the US, the account ID includes the region. You can find your account name from the browser address string.
99
114
100
-
If your web address is `https://myaccountname.snowflakecomputing.com/console#/internal/worksheet`, your account name would be `myaccountname`.
115
+
For example, if your web address is `https://myaccountname.snowflakecomputing.com/console#/internal/worksheet`, your account name would be `myaccountname`.
101
116
102
117
You can also find part of your account name by running the following query on your worksheet in Snowflake:
103
118
104
-
```
119
+
```sql
105
120
SELECT CURRENT_ACCOUNT();
106
121
```
107
122
4. Enter password when prompted.
@@ -145,55 +160,54 @@ USE WAREHOUSE "SEGMENT_WAREHOUSE";
145
160
USE DATABASE "SEGMENT_EVENTS";
146
161
```
147
162
148
-
### Connect Snowflake to Segment
163
+
### Step 6: Connect Snowflake to Segment
149
164
150
-
After creating a Snowflake warehouse, the next step is to connect Segment.
165
+
After configuring your Snowflake resources, connect them to Segment.
151
166
152
167
1. In the Segment App, select Add Destination.
153
168
2. Search for and select "Snowflake".
154
169
3. Add your credentials as follows:
155
-
- User - The user name (as created above).
156
-
- Password - The password for the user.
157
-
- Account - The account id of your cluster, not the url (for example, url: `my-business.snowflakecomputing.com`, account-id: `my-business`. **Note:** If you are using Snowflake on AWS, the account id includes the region, for example your url might look like: `my-business.us-east-1.snowflakecomputing.com/` and your accound-id would be: `my-business.us-east-1`)
158
-
- Database - The database name (as created above).
159
-
- Warehouse - The warehouse name (as created above).
170
+
-**User**: The user name that you created in [Step 4: Create user for Segment](#step-4-create-user-for-segment)
171
+
-**Password**: The password that you set in [Step 4: Create user for Segment](#step-4-create-user-for-segment)
172
+
-**Account**: The account id of your cluster, not the url (for example, url: `my-business.snowflakecomputing.com`, account-id: `my-business`. **Note:** If you are using Snowflake on AWS, the account id includes the region. For example, your url might be: `my-business.us-east-1.snowflakecomputing.com/` and your account-id would be: `my-business.us-east-1`)
173
+
-**Database**: The database name that you created in [Step 2: Create database](#step-2-create-database)
174
+
-**Warehouse**: The name of the warehouse that you created in [Step 1: Create a virtual warehouse](#step-1-create-a-virtual-warehouse)
160
175
161
176
## Security
162
177
163
178
### Allowlisting IPs
164
179
165
-
If you create a network policy with Snowflake, add the following IP addresses to the "Allowed IP Addresses" list: `52.25.130.38/32`, `34.223.203.0/28`
180
+
If you create a network policy with Snowflake and are located in the US, add `52.25.130.38/32` and `34.223.203.0/28` to the "Allowed IP Addresses" list.
181
+
182
+
If you create a network policy with Snowflake and are located in the EU, add `3.251.148.96/29` to your "Allowed IP Addresses" list.
166
183
167
184
### Multi-Factor Authentication (MFA) & SSO
168
185
169
186
At this time, the Segment Snowflake destination is not compatible with Snowflake's MFA or SSO settings. If your connected user has MFA or SSO enabled, you will need to disable it for syncs to run correctly.
170
187
171
188
## Best Practices
172
189
173
-
### Auto Suspend
174
-
175
-
Set `AUTO_SUSPEND` to ~10 minutes in the UI (or 600 if using SQL) to avoid credit consumption by the Segment syncing process.
176
-
190
+
### Auto Suspend and Auto Resume
177
191
178
-
### Auto Resume
192
+
Set `AUTO_SUSPEND` to ~10 minutes in the UI (or 600 if using SQL) to avoid Segment's syncing process credit consumption.
179
193
180
194
If you enable the `AUTO_SUSPEND` feature, Segment recommends that you also enable `AUTO-RESUME`. This will ensure that your Snowflake warehouse automatically resumes when Segment loads data. Otherwise, Segment will not be able to load data unless you [manually resume your Snowflake warehouse](https://docs.snowflake.net/manuals/user-guide/warehouses-considerations.html#automating-warehouse-resumption){:target="_blank"}.
181
195
182
196
### Unique Warehouse, Database, and Role
183
197
184
-
Segment recommends creating a unique Warehouse, Database and Role for the Segment Snowflake connection to your Snowflake instance.
198
+
Segment recommends creating a unique Warehouse, Database and Role for the Segment Snowflake connection to your Snowflake instance to avoid conflicts with other operations happening in your cluster.
185
199
186
200
## Troubleshooting
187
201
188
202
### I get "Object does not exist" when running "USE DATABASE" or "USE WAREHOUSE", even if the warehouse or the database are created.
189
203
190
-
Make sure you have created the role and assigned the proper permissions with the account `SYSADMIN` or `ACCOUNTADMIN`. Other non-system accounts don't assign the right permissions.
204
+
Make sure you created the role and assigned the proper permissions with the account `SYSADMIN` or `ACCOUNTADMIN`. Other non-system accounts don't assign the right permissions.
191
205
192
-
### I've consumed all the credits after the initial sync.
206
+
### I've consumed all my credits after the initial sync.
193
207
194
-
If you have used all your credits, you will need to contact Snowflake to purchase more.
208
+
If you have used all your credits, you must contact Snowflake to purchase more.
195
209
196
-
Also make sure `AUTO_SUSPEND` is enabled and set to 5 or 10 minutes in the warehouse used by Segment. This setting will help avoid unintended use of credits by the Segment Snowflake destination.
210
+
Also, make sure `AUTO_SUSPEND` is enabled and set to 5 or 10 minutes in the warehouse used by Segment. This setting helps avoid unintended use of credits by the Segment Snowflake destination.
197
211
198
212
### My syncs are going slower than I expect.
199
213
@@ -212,10 +226,10 @@ Most customers have the best luck starting with a X-Small instance.
212
226
A `rollback` is issued at the end of each session to make sure there's no "in-flight" processes hanging out that could block other processes later.
213
227
214
228
### Does Segment use transactions for loading data?
215
-
Segment doesn't open transactions explicitly because that would lock resources. However, if autocommit is enabled, each statement functions as it's own transaction, and a silent commit is issued after each.
229
+
Segment doesn't open transactions explicitly because that would lock resources. However, if `autocommit` is enabled, each statement functions as its own transaction, and a silent commit is issued after each.
216
230
217
231
### What privileges do I need to grant?
218
-
You shouldn't need to grant any additional privileges. However, you may need to confirm that the USAGE privilege on those schemas is granted to the same role granted to the user connecting to Snowflake through data bricks.
232
+
You shouldn't need to grant any additional privileges. However, you may need to confirm that the USAGE privilege on those schemas is granted to the same role granted to the user connecting to Snowflake through Databricks.
219
233
220
234
Run these statements in Snowflake UI or CLI, and check the output to verify the permissions.
0 commit comments