Skip to content

Commit 52f1377

Browse files
committed
Update tables doc
1 parent 066797b commit 52f1377

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

src/unify/profiles-sync/tables.md

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

225311
> info "dbt model definitions package"

0 commit comments

Comments
 (0)