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/redshift-setup.md
+49-50Lines changed: 49 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,12 @@ redirect_from:
11
11
12
12
Set up your Redshift data warehouse to Segment for the [Data Graph](/docs/unify/data-graph/).
13
13
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
+
14
20
## Getting started
15
21
16
22
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:
22
28
## Step 1: Roles and permissions
23
29
Segment recommends you to create a new Redshift user and role with only the required permissions.
24
30
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
+
26
40
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.
27
41
28
-
## Step 2: Create database for Segment to store checkpoint tables
42
+
## Step 2: Create a database for Segment to store checkpoint tables
29
43
30
44
> info ""
31
45
> 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.
32
46
33
47
Run the following SQL commands in your Redshift cluster:
34
48
35
-
```sql
49
+
```
36
50
-- ******** SET UP THE FOLLOWING WAREHOUSE PERMISSIONS ********
37
51
38
52
-- 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;
47
61
```
48
62
49
63
## 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.
51
67
52
68
### Schemas
53
69
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.
54
70
55
-
```sql
71
+
```
56
72
-- ********** REPEAT THE SQL QUERY BELOW FOR EACH SCHEMA YOU WANT TO USE FOR THE DATA GRAPH **********
57
73
58
74
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;
62
78
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"}.
63
79
64
80
Table permissions can either be handled in bulk:
65
-
```sql
81
+
```
66
82
-- query data from a all tables in a schema
67
83
GRANT SELECT ON ALL TABLES IN SCHEMA "the_schema_name" TO ROLE SEGMENT_LINKED_ROLE;
68
84
```
69
85
70
86
Or in a more granular fashion if needed:
71
-
```sql
87
+
```
72
88
-- query data from a specific table in a schema
73
89
GRANT SELECT ON TABLE <schema-name>.<table-name> TO ROLE segment_linked_role;
74
90
```
75
91
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.
76
94
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.
GRANT ROLE segment_entities TO segment_entities_user;
93
95
```
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.
SELECT * FROM "THE_READ_ONLY_DB.A_SCHEMA.SOME_TABLE" LIMIT 10;
106
98
```
107
99
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"}.
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:
115
117
```
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.
116
119
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;
118
122
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"}:
0 commit comments