Skip to content

Commit 77a3364

Browse files
authored
Merge pull request #6874 from segmentio/uditmehta27-patch-1
Update Snowflake Setup Guide
2 parents 1fe4be0 + 9eed382 commit 77a3364

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

src/unify/data-graph/setup-guides/snowflake-setup.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,30 @@ Log in to Snowflake with admin privileges to provide Segment Data Graph with the
2121

2222
Segment requires the following settings to connect to your Snowflake warehouse.
2323

24-
<img src="/docs/unify/images/snowflake-setup.png" alt="Connect Snowflake to the Data Graph" width="5888"/>
24+
<img src="/docs/unify/images/snowflake-setup.png" alt="Connect Snowflake to Data Graph" width="5888"/>
2525

2626
- **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.
2828
- **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.
2929
- **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.
3133

3234
## Set up Snowflake credentials
3335

3436
Segment recommends setting up a new Snowflake user and only giving this user permissions to access the required databases and schemas.
3537

36-
### Create Segment user and internal database
38+
### Step 1: Create Segment user and internal database
3739

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:
3941

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.
4143
- 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.
4348
4449
```
4550
-- ********** SET UP THE FOLLOWING WAREHOUSE PERMISSIONS **********
@@ -91,11 +96,11 @@ GRANT CREATE SCHEMA ON DATABASE identifier($segment_connection_db) TO ROLE iden
9196
9297
```
9398

94-
### Grant access to other databases
99+
### Step 2: Grant read-only access to other databases
95100

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**
97102

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**.
99104

100105
```
101106
@@ -117,7 +122,7 @@ GRANT SELECT ON FUTURE MATERIALIZED VIEWS IN DATABASE identifier($linked_read_on
117122
118123
```
119124

120-
### (Optional) Restrict Snowflake schema access
125+
### (Optional) Step 3: Restrict Snowflake schema access
121126

122127
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:
123128

@@ -143,7 +148,7 @@ GRANT SELECT ON FUTURE MATERIALIZED VIEWS IN SCHEMA identifier($linked_read_only
143148
144149
```
145150

146-
### (If applicable) Update user acccess for Segment Reverse ETL schema
151+
### (If applicable) Step 4: Update user acccess for Segment Reverse ETL schema
147152

148153
> warning ""
149154
> 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:
157162
```
158163
-- 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.
159164
160-
SET retl_schema = concat($segment_internal_database,'.__segment_reverse_etl');
165+
SET retl_schema = concat($segment_connection_db,'.__segment_reverse_etl');
161166
162167
GRANT USAGE ON SCHEMA identifier($retl_schema) TO ROLE identifier($segment_connection_role);
163168
@@ -167,7 +172,7 @@ GRANT SELECT,INSERT,UPDATE,DELETE ON ALL TABLES IN SCHEMA identifier($retl_schem
167172
168173
```
169174

170-
### Confirm permissions
175+
### Step 5: Confirm permissions
171176

172177
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.
173178

@@ -179,6 +184,6 @@ set table_name = 'YOUR_DB.SCHEMA.TABLE';
179184
USE ROLE identifier($segment_connection_role);
180185
USE DATABASE identifier($linked_read_only_database) ;
181186
SHOW SCHEMAS;
182-
SELECT * FROM identifier($table) LIMIT 10;
187+
SELECT * FROM identifier($table_name) LIMIT 10;
183188
184189
```

src/unify/images/snowflake-setup.png

515 KB
Loading

0 commit comments

Comments
 (0)