Skip to content

Commit 7b88890

Browse files
authored
Merge pull request #5640 from segmentio/profiles-sync-materilized-tables
Profiles Sync materialized tables
2 parents 53f26fb + 70fd642 commit 7b88890

File tree

2 files changed

+94
-5
lines changed

2 files changed

+94
-5
lines changed

src/unify/profiles-sync/index.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ You can access Selective Sync in two ways:
8585
- From the Set Selective Sync page as you connect your warehouse to Profiles Sync.
8686
- From the Profiles Sync settings (**Profiles Sync** > **Settings** > **Selective sync**).
8787

88-
You'll see a list of event type tables, event tables, and properties available to sync. Select the tables and properties that you'd like to sync, and be sure the ones you'd like to prevent from syncing aren't selected.
88+
You'll see a list of event type tables, event tables, and [tables Segment materializes](/docs/unify/profiles-sync/tables/#tables-segment-materializes) available to sync. Select the tables and properties that you'd like to sync, and be sure the ones you'd like to prevent from syncing aren't selected.
8989

9090
Regardless of schema size, only the first 5,000 collections and 5,000 properties per collection can be managed using your Segment space. To edit Selective Sync settings for any collection which exceeds this limit, [contact Segment support](https://app.segment.com/workspaces?contact=1){:target="blank"}.
9191

@@ -117,7 +117,6 @@ Segment lands the data on an internal staging location, then removes the backfil
117117

118118
Reach out to [Segment support](https://app.segment.com/workspaces?contact=1){:target="blank"} if your use case exceeds the scope of the initial setup backfill.
119119

120-
121120
> success ""
122121
> While historical backfill is running, you can start building [materialized views](/docs/unify/profiles-sync/tables/#tables-you-materialize) and running [sample queries](/docs/unify/profiles-sync/sample-queries).
123122
@@ -183,9 +182,7 @@ In the **Connection settings** tab, you can verify your synced warehouse’s cre
183182
If you have write access, you can verify that your warehouse is successfully connected to Segment by entering your password and then selecting **Test Connection**.
184183

185184
> info "Changing your synced warehouse"
186-
> If you’d like to change the warehouse connected to Profiles Sync, [reach out to Segment support](https://segment.com/help/contact/).
187-
188-
<!-- Verify that this doesn't need to be changed -->
185+
> If you’d like to change the warehouse connected to Profiles Sync, [reach out to Segment support](https://segment.com/help/contact/){:target="blank"}.
189186
190187
#### Sync schedule
191188

src/unify/profiles-sync/tables.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,98 @@ If your space has the same name as a source connected to your Segment Warehouse
220220
Follow the steps below to change your schema name:
221221
{% endcomment %}
222222

223+
## Tables Segment materializes
224+
225+
With Profiles Sync, you can access the following three tables that Segment materializes for a more complete view of your profile:
226+
- [`user_traits`](#the-user_traits-table)
227+
- [`user_identifiers`](#the-user_identifiers-table)
228+
- [`profile_merges`](#the-profile_merges-table)
229+
230+
Visit the [selective sync](/docs/unify/profiles-sync/#using-selective-sync) setup page to enable the following materialized tables, which Segment disables by default.
231+
232+
You can also use [historical backfill](/docs/unify/profiles-sync/#using-historical-backfill) with tables Segment materializes.
233+
234+
> warning ""
235+
> For materialized view tables, you must have delete permissions for your data warehouse.
236+
237+
238+
### The user_traits table
239+
240+
With the `user_traits` table, you'll see all traits that belong to a profile, represented by the `canonical_segment_id`. Use this table for a complete picture of your Profiles Sync data with external data sources such as customer purchase history, product usage, and more.
241+
242+
- This view is a fixed schema, and contains a row for each trait associated with the profile.
243+
- As new traits are added to the profile, new rows are added to the table.
244+
245+
When a merge occurs, two things happen:
246+
1. Segment deletes the **merge from** profile in the table, along with with all the traits that belong to it.
247+
2. Segment updates the **merge to** profile with the traits from the profile deleted in step 1.
248+
- For any conflicting traits, Segment appends the most recent trait to the profile.
249+
250+
251+
This table has the following columns:
252+
253+
| field | description |
254+
| ----------------------------- | --------------------------------------------------------------------------------------------------- |
255+
| `canonical_segment_id` | The fully-merged Segment ID (the profile Segment now understands any events or identifiers to map to). |
256+
| `name` | The name of the trait provided by a customer's Identify payload. |
257+
| `value` | The value of the trait provided by the customer's Identify payload. |
258+
| `seq` | A sequential value derived from the timestamp. Enables ordering/sorting within a given unique trait. |
259+
| `received_at` | The timestamp when the Segment API receives the payload from the client or server. |
260+
| `uuid_ts` | A unique identifier of the timestamp. |
261+
| `timestamp` | The UTC-converted timestamp set by the Segment library. |
262+
263+
264+
### The user_identifiers table
265+
266+
The `user_identifiers` table contains all external ID values that map to a profile, which is represented by the `canonical_segment_id`.
267+
268+
With the `user_identifiers` table:
269+
- There's one row per identifier associated with the profile. This view has a fixed schema.
270+
- As new identifiers are added to a profile, new rows are added to the table.
271+
272+
When a merge occurs:
273+
1. Segment deletes the **merge from** profile in the view, along with all associated identifiers.
274+
2. Segment updates the **merge to** profile with the identifiers that belonged to the profile deleted in step 1.
275+
276+
This table has the following columns:
277+
278+
279+
| field | description |
280+
| ----------------------------- | --------------------------------------------------------------------------------------------------- |
281+
| `canonical_segment_id` | The fully-merged Segment ID (the profile Segment now understands any events or identifiers to map to). |
282+
| `type` | The type of external identifier sent in the incoming event, such as `user_id` or `anonymous_id`. External identifiers become the identities attached to a user profile. |
283+
| `value` | The value of the trait provided by the customer's Identify payload. |
284+
| `seq` | A sequential value derived from the timestamp. Enables ordering/sorting within a given unique trait. |
285+
| `received_at` | The timestamp when the Segment API receives the payload from the client or server. |
286+
| `uuid_ts` | A unique identifier of the timestamp. |
287+
| `timestamp` | The UTC-converted timestamp set by the Segment library. |
288+
289+
### The profile_merges table
290+
291+
The `profile_merges` table contains all mappings from a `segment_id` to a profile, represented by the `canonical_segment_id`. This mapping indicates that a profile has been created within Segment.
292+
293+
With the `profile_merges` table:
294+
- There's one row per profile associated with the `canonical_segment_id` that represents the profile. This view is a fixed schema.
295+
- When a profile is created, a new row is created with the `segment_id` and `canonical_segment_id` having the same value.
296+
297+
298+
When a merge occurs:
299+
1. Segment deletes the **merge from** profile, along with all Segment IDs that belong to it.
300+
2. Segment updates the **merge to** profile with Segment IDs that previously belonged to the profile deleted in step 1.
301+
302+
This table has the following columns:
303+
304+
305+
| field | description |
306+
| ----------------------------- | --------------------------------------------------------------------------------------------------- |
307+
| `canonical_segment_id` | The fully-merged Segment ID (the profile Segment now understands any events or identifiers to map to). |
308+
| `segment_id` | The profile ID that Segment appends to an event or an identifier at the time it was first observed. |
309+
| `seq` | A sequential value derived from the timestamp. Enables ordering/sorting within a given unique trait. |
310+
| `received_at` | The timestamp when the Segment API receives the payload from the client or server. |
311+
| `uuid_ts` | A unique identifier of the timestamp. |
312+
| `timestamp` | The UTC-converted timestamp set by the Segment library. |
313+
314+
223315
## Tables you materialize
224316

225317
> info "dbt model definitions package"

0 commit comments

Comments
 (0)