id-graph-ids-to-canonical-id
ID Graph - IDs to Canonical ID
Detect over-stitching by finding individual IDs that appear across multiple canonical ID groups.
Requirements
- Parent segment ID with RT 2.0 enabled
Database
The database name contains the parent segment ID and has this format cdp_audience_411671. This is where you can plug in the parent segment the user gives in the request.
ids_updated table
The ID graph table is typically called ids_updated and is in the Parent Segment real time database. This table contains the canonical ID mappings created by RT 2.0's ID stitching process.
Schema
The ids_updated table has the following key columns:
- canonical_id, string, the canonical identifier for a group of stitched IDs
- id_set, array(string), array of individual identifiers that belong to this canonical group
Core Query
The main query to identify individual IDs mapping to multiple canonical IDs:
WITH flattened_ids AS (
SELECT
canonical_id,
individual_id
FROM cdp_audience_<parent_segment_id>.ids_updated
CROSS JOIN UNNEST(id_set) AS t(individual_id)
WHERE td_interval(time, '-7d') -- Avoid full table scan
),
id_counts AS (
SELECT
individual_id,
COUNT(DISTINCT canonical_id) as canonical_count,
ARRAY_AGG(DISTINCT canonical_id) as canonical_ids
FROM flattened_ids
GROUP BY individual_id
)
SELECT
individual_id,
canonical_count,
canonical_ids
FROM id_counts
WHERE canonical_count > 1 -- Only show over-stitching cases
ORDER BY canonical_count DESC, individual_id
LIMIT 100;
More from treasure-data/td-skills
pytd
Expert assistance for using pytd (Python SDK) to query and import data with Treasure Data. Use this skill when users need help with Python-based data analysis, querying Presto/Hive, importing pandas DataFrames, bulk data uploads, or integrating TD with Python analytical workflows.
20tdx-basic
Executes tdx CLI commands for Treasure Data. Covers `tdx databases`, `tdx tables`, `tdx describe`, `tdx query`, `tdx auth setup`, context management with profiles/sessions, and output formats (JSON/TSV/table). Use when users need tdx command syntax, authentication setup, database/table exploration, schema inspection, or query execution.
3workflow
Manages TD workflows using `tdx wf` commands. Covers project sync (pull/push/clone), running workflows, monitoring sessions/attempts, task timeline visualization, retry/kill operations, and secrets management. Use when users need to manage, monitor, or debug Treasure Workflow projects via tdx CLI.
3journey
Load when the client wants to create, edit, or manage a CDP customer journey. Use for building journey YAML with segments, activations, and stage steps, modifying journey stages or flow logic (decision points, condition waits, A/B tests), or pushing journey changes to Treasure Data. Also load when the client wants to analyze journey performance, query journey tables, create journey dashboards, or generate journey action reports.
2parent-segment-analysis
Query and analyze CDP parent segment database data. Use `tdx ps desc -o` to get output database schema, then query customers and behavior tables. Use when exploring parent segment data, building reports, or analyzing customer attributes and behaviors.
2connector-config
Writes connector_config for segment/journey activations using `tdx connection schema <type>` to discover available fields. Use when configuring activations - always run schema command first to see connector-specific fields.
2