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/unify/data-graph/setup-guides/snowflake-setup.md
+20-15Lines changed: 20 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -21,25 +21,30 @@ Log in to Snowflake with admin privileges to provide Segment Data Graph with the
21
21
22
22
Segment requires the following settings to connect to your Snowflake warehouse.
23
23
24
-
<imgsrc="/docs/unify/images/snowflake-setup.png"alt="Connect Snowflake to the Data Graph"width="5888"/>
24
+
<imgsrc="/docs/unify/images/snowflake-setup.png"alt="Connect Snowflake to Data Graph"width="5888"/>
25
25
26
26
-**Account ID**: The Snowflake account ID that uniquely identifies your organization account.
27
-
-**Database Name**: The only database that Segment requires write access to in order to create tables for internal bookkeeping. This database is referred to as `segment_connection_db` in the script below.
27
+
-**Database**: The only database that Segment requires write access to in order to create tables for internal bookkeeping. This database is referred to as `segment_connection_db` in the script below.
28
28
-**Warehouse**: The [warehouse](https://docs.snowflake.com/en/user-guide/warehouses){:target="_blank”} in your Snowflake account that you want to use for Segment to run the SQL queries. This warehouse is referred to as `segment_connection_warehouse` in the script below.
29
29
-**Username**: The Snowflake user that Segment uses to run SQL in your warehouse. This user is referred to as `segment_connection_username` in the script below.
30
-
-**Password**: The password of the user above. This password is referred to as `segment_connection_password` in the script below.
30
+
-**Authentication**: There are 2 supported authentication methods:
31
+
1.**Key Pair**: This is the recommended method of authentication. You would need to first create the user and assign it a key pair following the instructions in the [Snowflake docs](https://docs.snowflake.com/en/user-guide/key-pair-auth). Then, follow the Segment docs above to set up Snowflake permissions and set the `segment_connections_username` variable in the SQL script to the user you just created.
32
+
2.**Password**: The password of the user above. This password is referred to as `segment_connection_password` in the script below.
31
33
32
34
## Set up Snowflake credentials
33
35
34
36
Segment recommends setting up a new Snowflake user and only giving this user permissions to access the required databases and schemas.
35
37
36
-
### Create Segment user and internal database
38
+
### Step 1: Create Segment user and internal database
37
39
38
-
Use the following steps to set up your Snowflake credentials:
40
+
The first step is to create a new Segment role and grant it the appropriate permissions. Run the SQL code block below in your SQL worksheet in Snowflake. It executes the following commands:
39
41
40
-
- Create a new role and user for Segment Data Graph.
42
+
- Create a new role and user for Segment Data Graph. This new role will have access to only the datasets you want to access from the Segment Data Graph.
41
43
- Grant the Segment user access to the warehouse of your choice. If you'd like to create a new warehouse, uncomment the SQL below.
42
-
- Create a new database for Segment Data Graph. Segment only requires write access to this one database to create a schema for internal bookkeeping, and to store checkpoint tables for the queries that are executed. Segment recommends creating an empty database for this purpose using the script below. This is also the database you'll be required to specify for the "Database Name" when connecting Snowflake with the Segment app.
44
+
- Create a new database for Segment Data Graph. **Segment only requires write access to this one database to create a schema for internal bookkeeping, and to store checkpoint tables for the queries that are executed**. Segment recommends creating an empty database for this purpose using the script below. This is also the database you'll be required to specify for the "Database Name" when connecting Snowflake with the Segment app.
45
+
46
+
> info ""
47
+
> The variables specified at the top of the code block with the `SET` command are placeholders and should be updated.
43
48
44
49
```
45
50
-- ********** SET UP THE FOLLOWING WAREHOUSE PERMISSIONS **********
@@ -91,11 +96,11 @@ GRANT CREATE SCHEMA ON DATABASE identifier($segment_connection_db) TO ROLE iden
91
96
92
97
```
93
98
94
-
### Grant access to other databases
99
+
### Step 2: Grant read-only access to other databases
95
100
96
-
Next, give the Segment user**read-only** access to all the other databases you want to use for Data Graph. You must grant access to the Profiles Sync database.
101
+
Next, give the Segment role**read-only** access to all the other databases you want to use for Data Graph including the **Profiles Sync database**
97
102
98
-
Run the SQL query below for **each** database you want to use for Data Graph:
103
+
Run the SQL query below for **each** database you want to use for Data Graph. **You may have to re-run this multiple times for each database you want to give access to**.
99
104
100
105
```
101
106
@@ -117,7 +122,7 @@ GRANT SELECT ON FUTURE MATERIALIZED VIEWS IN DATABASE identifier($linked_read_on
If you want to restrict access to specific [Snowflake schemas and tables](https://docs.snowflake.com/en/user-guide/security-access-control-privileges#table-privileges){:target="_blank”}, run the following commands:
123
128
@@ -143,7 +148,7 @@ GRANT SELECT ON FUTURE MATERIALIZED VIEWS IN SCHEMA identifier($linked_read_only
143
148
144
149
```
145
150
146
-
### (If applicable) Update user acccess for Segment Reverse ETL schema
151
+
### (If applicable) Step 4: Update user acccess for Segment Reverse ETL schema
147
152
148
153
> warning ""
149
154
> This is only applicable if you choose to use an existing database as the Segment connection database that has also been used for Segment Reverse ETL.
@@ -157,7 +162,7 @@ Add the Snowflake table permissions by running the following commands:
157
162
```
158
163
-- If you want to use an existing database that already has Segment Reverse ETL schemas, you’ll need to run some additional steps below to grant the role access to the existing schemas.
159
164
160
-
SET retl_schema = concat($segment_internal_database,'.__segment_reverse_etl');
165
+
SET retl_schema = concat($segment_connection_db,'.__segment_reverse_etl');
161
166
162
167
GRANT USAGE ON SCHEMA identifier($retl_schema) TO ROLE identifier($segment_connection_role);
163
168
@@ -167,7 +172,7 @@ GRANT SELECT,INSERT,UPDATE,DELETE ON ALL TABLES IN SCHEMA identifier($retl_schem
167
172
168
173
```
169
174
170
-
### Confirm permissions
175
+
### Step 5: Confirm permissions
171
176
172
177
To verify you have set up the right permissions for a specific table, log in with the username and password you created for `SEGMENT_CONNECTION_USERNAME` and run the following command to verify the role you created has the correct permissions. If this command succeeds, you should be able to view the respective table.
173
178
@@ -179,6 +184,6 @@ set table_name = 'YOUR_DB.SCHEMA.TABLE';
179
184
USE ROLE identifier($segment_connection_role);
180
185
USE DATABASE identifier($linked_read_only_database) ;
0 commit comments