Skip to content

Commit a3a7d2b

Browse files
committed
[netlify-build]
1 parent 5723d48 commit a3a7d2b

File tree

1 file changed

+49
-50
lines changed

1 file changed

+49
-50
lines changed

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

Lines changed: 49 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ redirect_from:
1111
1212
Set up your Redshift data warehouse to Segment for the [Data Graph](/docs/unify/data-graph/).
1313

14+
## Prerequisites
15+
16+
To use Linked Audiences with Redshift, Segment requires you to configure [Profiles Synce materialized views for the Data Graph](/docs/unify/data-graph/#prerequisites). You can read more about [Profile Sync materialized views](/docs/unify/profiles-sync/tables/#tables-segment-materializes).
17+
18+
Even though Segment only supports Profile Sync materialized tables for the Data Graph, Linked Audiences require Profile Sync to be configured such that both the [Profile raw tables](/docs/unify/profiles-sync/tables/#profile-raw-tables) and the [Profile materialized tables](/docs/unify/profiles-sync/tables/#tables-segment-materializes) are synchronized with your Redshift instance.
19+
1420
## Getting started
1521

1622
You need to be an account admin to set up the Segment Redshift connector as well as write permissions for the `__segment_reverse_etl` dataset.
@@ -22,17 +28,25 @@ To get started with Redshift:
2228
## Step 1: Roles and permissions
2329
Segment recommends you to create a new Redshift user and role with only the required permissions.
2430

25-
1. Create a new role and user for the Segment Data Graph. This new role will only have access to the datasets you provide access to for the Data Graph.
31+
1. Create a new role and user for the Segment Data Graph. This new role will only have access to the datasets you provide access to for the Data Graph. Run the SQL commands in your Redshift cluster:
32+
33+
```
34+
-- Create a user with role for the Data Graph
35+
CREATE ROLE SEGMENT_LINKED_ROLE;
36+
CREATE USER SEGMENT_LINKED_USER PASSWORD "your_password";
37+
GRANT ROLE SEGMENT_LINKED_ROLE TO SEGMENT_LINKED_USER;
38+
```
39+
2640
2. Provide write access to the database as Segment requires this in order to create a schema for internal bookkeeping and to store checkpoint tables for the queries that are executed. Segment recommends you to create a new database for this purpose. This is also the database you'll be required to specify for the **Database Name** when connecting Redshift with the Segment app.
2741

28-
## Step 2: Create database for Segment to store checkpoint tables
42+
## Step 2: Create a database for Segment to store checkpoint tables
2943

3044
> info ""
3145
> Segment recommends you to create a new database for the Data Graph. If you choose to use an existing database that has also been used for [Segment Reverse ETL](/docs/connections/reverse-etl/), you must follow the [additional instructions](#update-user-access-for-segment-reverse-etl-schema) to update user access for the Segment Reverse ETL schema.
3246
3347
Run the following SQL commands in your Redshift cluster:
3448

35-
```sql
49+
```
3650
-- ******** SET UP THE FOLLOWING WAREHOUSE PERMISSIONS ********
3751
3852
-- Create a user with role for the Data Graph
@@ -47,12 +61,14 @@ GRANT CREATE ON DATABASE SEGMENT_LINKED_PROFILES_DB TO ROLE SEGMENT_LINKED_ROLE;
4761
```
4862

4963
## Step 3: Grant read-only access for the Data Graph
50-
Give the Segment role read-only access to additional schemas you want to use for Data Graph including the Profiles Sync database.
64+
Grant the Segment role read-only access to additional schemas you want to use for the Data Graph including the Profiles Sync database.
65+
66+
To locate the Profile Sync database, navigate to **Unify > Profiles Sync > Settings > Connection Settings**. You will see the database and schema name.
5167

5268
### Schemas
5369
Grant schema permissions based on customer need. See Amazon’s docs to view [schema permissions](https://docs.aws.amazon.com/redshift/latest/dg/r_GRANT.html){:target="_blank"} and [example commands](https://docs.aws.amazon.com/redshift/latest/dg/r_GRANT-examples.html){:target="_blank"} that you can use to grant permissions. Repeat the following SQL query for each schema you want to use for the Data Graph.
5470

55-
```sql
71+
```
5672
-- ********** REPEAT THE SQL QUERY BELOW FOR EACH SCHEMA YOU WANT TO USE FOR THE DATA GRAPH **********
5773
5874
GRANT USAGE ON SCHEMA "the_schema_name" TO ROLE SEGMENT_LINKED_ROLE;
@@ -62,64 +78,47 @@ GRANT USAGE ON SCHEMA "the_schema_name" TO ROLE SEGMENT_LINKED_ROLE;
6278
Grant table permissions based on your needs. Learn more about [Amazon’s table permissions](https://docs.aws.amazon.com/redshift/latest/dg/r_GRANT.html){:target="_blank"}.
6379

6480
Table permissions can either be handled in bulk:
65-
```sql
81+
```
6682
-- query data from a all tables in a schema
6783
GRANT SELECT ON ALL TABLES IN SCHEMA "the_schema_name" TO ROLE SEGMENT_LINKED_ROLE;
6884
```
6985

7086
Or in a more granular fashion if needed:
71-
```sql
87+
```
7288
-- query data from a specific table in a schema
7389
GRANT SELECT ON TABLE <schema-name>.<table-name> TO ROLE segment_linked_role;
7490
```
7591

92+
## Step 4: Validate permissions
93+
To verify you have set up the right permissions for a specific table, log in with the username and password you created for `SEGMENT_LINKED_USER` 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.
7694

77-
## Create a new role and user
78-
79-
Run the SQL commands below to create a role (`segment_entities`) and user (`segment_entities_user`).
80-
81-
```sql
82-
-- create role
83-
CREATE ROLE segment_entities;
84-
85-
-- allow the role to create new schemas on specified database. (This is the name you chose when provisioning your cluster)
86-
GRANT CREATE ON DATABASE "<enter database name here>" TO ROLE segment_entities;
87-
88-
-- create a user named "segment_entities_user" that Segment will use when connecting to your Redshift cluster.
89-
CREATE USER segment_entities_user PASSWORD '<enter password here>';
90-
91-
-- grant role permissions to the user
92-
GRANT ROLE segment_entities TO segment_entities_user;
9395
```
94-
95-
## Grant access to schemas and tables
96-
97-
You'll need to grant access to schemas and tables that you'd like to enrich with. This allows Segment to list schemas, tables, and columns, as well as create entities with data extracted and ingested to Segment.
98-
99-
### Schemas
100-
101-
Grant schema permissions based on customer need. Visit Amazon's docs to view [schema permissions](https://docs.aws.amazon.com/redshift/latest/dg/r_GRANT.html){:target="_blank"} and [example commands](https://docs.aws.amazon.com/redshift/latest/dg/r_GRANT-examples.html){:target="_blank"} that you can use to grant permissions.
102-
103-
```ts
104-
-- view specific schemas in database
105-
GRANT USAGE ON SCHEMA <schema-name> TO ROLE segment_entities;
96+
SHOW SCHEMAS FROM DATABASE "THE_READ_ONLY_DB";
97+
SELECT * FROM "THE_READ_ONLY_DB.A_SCHEMA.SOME_TABLE" LIMIT 10;
10698
```
10799

108-
### Tables
109-
110-
Grant table permissions based on customer need. Learn more about Amazon's [table permissions](https://docs.aws.amazon.com/redshift/latest/dg/r_GRANT.html){:target="_blank"}.
111-
112-
```ts
113-
-- query data from a specific table in a schema
114-
GRANT SELECT ON TABLE <schema-name>.<table-name> TO ROLE segment_entities;
100+
## Step 5: Connect your warehouse to Segment
101+
To connect your warehouse to Segment:
102+
1. Navigate to **Unify > Data Graph**. This should be a Unify space with Profiles Sync already set up.
103+
2. Click **Connect warehouse**.
104+
3. Select **Redshift** as your warehouse type.
105+
4. Enter your warehouse credentials. Segment requires the following settings to connect to your Redshift warehouse:
106+
* **Host Name:** The Redshift URL
107+
* **Port:** The Redshift connection port
108+
* **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_linked_profiles_db` in the SQL above
109+
* **Username:** The Redshift user that Segment uses to run SQL in your warehouse. This user is referred to as `segment_linked_user` in the sql above
110+
* **Password:** The password of the user above
111+
5. Test your connection, then click **Save**.
112+
113+
## Update user access for Segment Reverse ETL dataset
114+
If Segment Reverse ETL ran in the project you are configuring as the Segment connection project, a Segment-managed dataset is already created, and you need to provide the new Segment user access to the existing dataset. Run the following SQL if you run into an error on the Segment app indicating that the user doesn’t have sufficient privileges on an existing `__segment_reverse_etl`.
115+
116+
Run the following command:
115117
```
118+
-- 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.
116119
117-
### RETL table permissions
120+
GRANT USAGE, CREAT, DROP ON SCHEMA segment_connection_db.__segment_reverse_etl TO ROLE SEGMENT_LINKED_ROLE;
121+
GRANT CREATE TABLE ON SCHEMA identifier($retl_schema) TO ROLE SEGMENT_LINKED_ROLE;
118122
119-
If you used RETL in your database, you'll need to add the following [table permissions](https://docs.aws.amazon.com/redshift/latest/dg/r_GRANT.html){:target="_blank"}:
120-
121-
```ts
122-
GRANT USAGE, CREATE ON SCHEMA __segment_reverse_etl TO ROLE segment_entities;
123-
124-
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA __segment_reverse_etl TO ROLE segment_entities;
125-
```
123+
GRANT SELECT,INSERT,UPDATE,DELETE,DROP ON ALL TABLES IN SCHEMA segment_connection_db.__segment_reverse_etl TO ROLE SEGMENT_LINKED_ROLE;
124+
```

0 commit comments

Comments
 (0)