Skip to content

Commit 1729574

Browse files
authored
Merge pull request #7308 from segmentio/DOC-1016
Redshift Data Graph Public Beta Setup Docs [DOC-1016]
2 parents 379a98f + e8baaec commit 1729574

File tree

3 files changed

+86
-34
lines changed

3 files changed

+86
-34
lines changed

src/_data/sidenav/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ sections:
362362
title: BigQuery Data Graph Setup
363363
- path: /unify/data-graph/setup-guides/databricks-setup/
364364
title: Databricks Data Graph Setup
365+
- path: /unify/data-graph/setup-guides/redshift-setup/
366+
title: Redshift Data Graph Setup
365367
- path: /unify/data-graph/setup-guides/snowflake-setup/
366368
title: Snowflake Data Graph Setup
367369
- section_title: Linked Events

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Databricks Setup
2+
title: Databricks Data Graph Setup
33
plan: unify
44
redirect_from:
55
- '/unify/linked-profiles/setup-guides/databricks-setup'

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

Lines changed: 83 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,71 +2,121 @@
22
title: Redshift Data Graph Setup
33
beta: true
44
plan: unify
5-
hidden: true
65
redirect_from:
76
- '/unify/linked-profiles/setup-guides/redshift-setup'
87
---
98

10-
> info "Linked Audiences is in public beta"
11-
> Linked Audiences (with Data Graph, Linked Events) is in public beta, and Segment is actively working on this feature. Some functionality may change before it becomes generally available.
12-
139
> info ""
14-
> At this time, you can only use Redshift with Linked Events.
10+
> Redshift for Data Graph is in beta and Segment is actively working on this feature. Some functionality may change before it becomes generally available. This feature is governed by Twilio Segment’s [First Access and Beta Preview Terms](https://www.twilio.com/en-us/legal/tos){:target="_blank"}.
11+
12+
Set up your Redshift data warehouse to Segment for the [Data Graph](/docs/unify/data-graph/).
13+
14+
## Prerequisite
1515

16-
On this page, you'll learn how to connect your Redshift data warehouse to Segment.
16+
To use Linked Audiences with Redshift, the Data Graph only supports [materialized views](/docs/unify/profiles-sync/tables/#tables-segment-materializes).
17+
18+
If you're setting up Profiles Sync for the first time in the Unify space, go through the setup flow for Selective sync. If Profiles Sync is already set up for your Unify space, follow these steps to configure Profiles Sync for your Unify space:
19+
20+
1. Navigate to **Unify > Profile Sync**.
21+
2. Select the **Settings** tab and select **Selective sync**.
22+
3. Select all the tables under **Profile raw tables**. These include, `external_id_mapping_updates`, `id_graph_updates`, `profile_traits_updates`. Linked Audiences require Profile Sync to be configured such that both the Profile raw tables and the Profile materialized tables are synchronized with your Redshift instance.
23+
4. Select all of the tables under **Profile materialized tables**. These include `profile_merges`, `user_traits`, `user_identifiers`. This allows faster and more cost-efficient Linked Audiences computations in your data warehouse.
24+
5. Select **Sync all Track Call Tables** under **Track event tables** to enable filtering on event history for Linked Audiences conditions.
1725

1826
## Getting started
1927

28+
You need to be an AWS Redshift account admin to set up the Segment Redshift connector as well as write permissions for the `__segment_reverse_etl` dataset.
29+
2030
To get started with Redshift:
2131
1. Log in to Redshift and select the Redshift cluster you want to connect.
22-
2. Follow these [networking instructions](/docs/connections/storage/catalog/redshift/#networking) to configure network and security settings.
32+
2. Follow the [networking instructions](/docs/connections/storage/catalog/redshift/#networking) to configure network and security settings.
2333

24-
## Create a new role and user
34+
## Step 1: Roles and permissions
35+
Segment recommends you to create a new Redshift user and role with only the required permissions.
2536

26-
Run the SQL commands below to create a role (`segment_entities`) and user (`segment_entities_user`).
37+
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:
2738

28-
```sql
29-
-- create role
30-
CREATE ROLE segment_entities;
39+
```sql
40+
-- Create a user with role for the Data Graph
41+
CREATE ROLE SEGMENT_LINKED_ROLE;
42+
CREATE USER SEGMENT_LINKED_USER PASSWORD "your_password";
43+
GRANT ROLE SEGMENT_LINKED_ROLE TO SEGMENT_LINKED_USER;
44+
```
45+
46+
## Step 2: Create a database for Segment to store checkpoint tables
47+
48+
> info ""
49+
> 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-dataset) to update user access for the Segment Reverse ETL schema.
50+
51+
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.
3152

32-
-- allow the role to create new schemas on specified database. (This is the name you chose when provisioning your cluster)
33-
GRANT CREATE ON DATABASE "<enter database name here>" TO ROLE segment_entities;
53+
Run the following SQL commands in your Redshift cluster:
3454

35-
-- create a user named "segment_entities_user" that Segment will use when connecting to your Redshift cluster.
36-
CREATE USER segment_entities_user PASSWORD '<enter password here>';
55+
```sql
56+
-- Create and Grant access to a Segment internal DB used for bookkeeping
3757

38-
-- grant role permissions to the user
39-
GRANT ROLE segment_entities TO segment_entities_user;
58+
CREATE DATABASE SEGMENT_LINKED_PROFILES_DB;
59+
GRANT CREATE ON DATABASE SEGMENT_LINKED_PROFILES_DB TO ROLE SEGMENT_LINKED_ROLE;
4060
```
4161

42-
## Grant access to schemas and tables
62+
## Step 3: Grant read-only access for the Data Graph
63+
Grant the Segment role read-only access to additional schemas you want to use for the Data Graph including the Profiles Sync database.
4364

44-
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.
65+
To locate the Profile Sync database, navigate to **Unify > Profiles Sync > Settings > Connection Settings**. You will see the database and schema name.
4566

4667
### Schemas
68+
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.
4769

48-
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.
70+
```sql
71+
-- ********** REPEAT THE SQL QUERY BELOW FOR EACH SCHEMA YOU WANT TO USE FOR THE DATA GRAPH **********
4972

50-
```ts
51-
-- view specific schemas in database
52-
GRANT USAGE ON SCHEMA <schema-name> TO ROLE segment_entities;
73+
GRANT USAGE ON SCHEMA "the_schema_name" TO ROLE SEGMENT_LINKED_ROLE;
5374
```
5475

55-
### Tables
76+
### Table
77+
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"}.
78+
79+
Table permissions can either be handled in bulk:
80+
81+
```sql
82+
-- query data from all tables in a schema
83+
GRANT SELECT ON ALL TABLES IN SCHEMA "the_schema_name" TO ROLE SEGMENT_LINKED_ROLE;
84+
```
5685

57-
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"}.
86+
Or in a more granular fashion if needed:
5887

59-
```ts
88+
```sql
6089
-- query data from a specific table in a schema
61-
GRANT SELECT ON TABLE <schema-name>.<table-name> TO ROLE segment_entities;
90+
GRANT SELECT ON TABLE <schema-name>.<table-name> TO ROLE segment_linked_role;
6291
```
6392

64-
### RETL table permissions
93+
## Step 4: Validate permissions
94+
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.
6595

66-
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"}:
96+
```sql
97+
SHOW SCHEMAS FROM DATABASE "THE_READ_ONLY_DB";
98+
SELECT * FROM "THE_READ_ONLY_DB.A_SCHEMA.SOME_TABLE" LIMIT 10;
99+
```
67100

68-
```ts
69-
GRANT USAGE, CREATE ON SCHEMA __segment_reverse_etl TO ROLE segment_entities;
101+
## Step 5: Connect your warehouse to Segment
102+
To connect your warehouse to Segment:
103+
1. Navigate to **Unify > Data Graph**. This should be a Unify space with Profiles Sync already set up.
104+
2. Click **Connect warehouse**.
105+
3. Select **Redshift** as your warehouse type.
106+
4. Enter your warehouse credentials. Segment requires the following settings to connect to your Redshift warehouse:
107+
* **Host Name:** The Redshift URL
108+
* **Port:** The Redshift connection port
109+
* **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.
110+
* **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.
111+
* **Password:** The password of the user above
112+
5. Test your connection, then click **Save**.
113+
114+
## Update user access for Segment Reverse ETL dataset
115+
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`:
116+
117+
```sql
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.
70119

71-
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA __segment_reverse_etl TO ROLE segment_entities;
120+
GRANT USAGE, CREATE, DROP ON SCHEMA segment_connection_db.__segment_reverse_etl TO ROLE SEGMENT_LINKED_ROLE;
121+
GRANT SELECT,INSERT,UPDATE,DELETE,DROP ON ALL TABLES IN SCHEMA segment_connection_db.__segment_reverse_etl TO ROLE SEGMENT_LINKED_ROLE;
72122
```

0 commit comments

Comments
 (0)