Warehouse Tables and SQL
A graph with a realtime half writes what realtime identity knows into the graph’s output schema in your warehouse (cdp_identity unless you chose another), beside the tables your warehouse resolution already writes. This page describes those tables and the SQL to use them.
The tables
| Table | One row per | Columns |
|---|---|---|
_IDENTITY_IDENTIFIERS | identifier value | family, value_key, ss_id (the profile ID), ownership, owner_reason, match_type, min_confidence, first_seen, last_seen |
_IDENTITY_ID_MAP | retired profile ID | profile_id, current_profile_id, changed_at, kind |
_IDENTITY_SSID_MOVES | profile ID that moved on the last run | old_ss_id, new_ss_id, kind, run_id, moved_at |
rt_obs_<graph> | pair of identifiers realtime linked, per day | workspace_id, graph_id, profile_id, the identifiers, trust, first_ms, received_at |
rt_chg_<graph> | change to a profile | every merge, split and correction, with its reason and time |
ownershipsays how an identifier belongs to its profile:owned(only this person carries it),attributed(several people carry it and shared identifier attribution chose this one),shared(it links no one: several people carry it, or, withowner_reasonsurplus, it is beyond its person’s per-profile limit) ornonlinking(its family forms no links, for example one matched only probabilistically). A value on your blocked-values list has no row.first_seenandlast_seenare the earliest and latest timestamps of the model rows carrying the value, from each model’s timestamp column.first_seennever moves later. A value only carried by models with no timestamp column takes the time of the run that first saw it, andlast_seenis the latest run.value_keyholds emails, phone numbers and other personal identifiers as their SHA-256 hashes, normalised exactly as the SDKs and the identity API do.ss_idis the profile ID realtime identity uses for the same person (see Realtime and Warehouse Identity).
Today’s person for a historical event
When the Identity enrichment adds the profile ID to your events, each event in your warehouse keeps the profile ID it had when it arrived. One join turns it into today’s:
SELECT e.*,
COALESCE(m.current_profile_id, JSON_VALUE(e.enrichment, '$.identity.profile_id')) AS person_id
FROM events e
LEFT JOIN cdp_identity._IDENTITY_ID_MAP m
ON m.profile_id = JSON_VALUE(e.enrichment, '$.identity.profile_id')SELECT e.*,
COALESCE(m.current_profile_id, e.enrichment:identity:profile_id::string) AS person_id
FROM events e
LEFT JOIN cdp_identity._IDENTITY_ID_MAP m
ON m.profile_id = e.enrichment:identity:profile_id::stringSELECT e.*,
COALESCE(m.current_profile_id, get_json_object(e.enrichment, '$.identity.profile_id')) AS person_id
FROM events e
LEFT JOIN cdp_identity._IDENTITY_ID_MAP m
ON m.profile_id = get_json_object(e.enrichment, '$.identity.profile_id')SELECT e.*,
if(m.current_profile_id != '', m.current_profile_id, JSONExtractString(e.enrichment, 'identity', 'profile_id')) AS person_id
FROM events AS e
LEFT JOIN cdp_identity._IDENTITY_ID_MAP AS m
ON m.profile_id = JSONExtractString(e.enrichment, 'identity', 'profile_id')SELECT e.*,
COALESCE(m.current_profile_id, JSON_EXTRACT_PATH_TEXT(e.enrichment, 'identity', 'profile_id')) AS person_id
FROM events e
LEFT JOIN cdp_identity._IDENTITY_ID_MAP m
ON m.profile_id = JSON_EXTRACT_PATH_TEXT(e.enrichment, 'identity', 'profile_id')The ID map is complete for merges: a merged-away ID always maps to the ID it became, however many merges followed, and an ID that was never merged has no row, which is why the join keeps the event’s own ID.
After a split
A split gives the part that left a new profile ID, while the ID map keeps the original ID for the part that stayed. To place each historical event with the person who holds its identifier today, join the event’s identifier to _IDENTITY_IDENTIFIERS instead:
SELECT e.*, i.ss_id AS person_id
FROM events e
JOIN cdp_identity._IDENTITY_IDENTIFIERS i
ON i.family = 'user_id' AND i.value_key = e.user_idFor a hashed family, join on the hash of the normalised value: for example i.family = 'email' and i.value_key = TO_HEX(SHA256(LOWER(TRIM(e.email)))) on BigQuery.
Profiles that moved on a run
_IDENTITY_SSID_MOVES lists every profile ID that changed on the last warehouse run (merge, split, rename or mixed), so a downstream job can update what it stored without comparing whole tables.
These tables are refreshed on every warehouse run of the graph. A graph with only a warehouse half does not write them.