early-table-25049
12/02/2023, 7:22 AMtracks table where I want create an ID graph of anonymous_id and user_id. I want to -
• Stitch pre-login and post-login events together
• Users can login from various devices so I want to stitch multiple devices belonging to a user together as well
To do this, I was trying the dbt-id-stitching package and tried using it on a dummy dataset on Snowflake. I've not been able to get it to work though so need another pair of eyes to confirm if I'm doing something wrong here.
I have anonymous_id and user_id coming in from the tracks table like so in a table called id_mapping
ANONYMOUS_ID, EMAIL
1, abc@gmail.com
1, a@gmail.com
1, null
2, a@gmail.com
3, b@gmail.com
3, null
4, c@gmail.com
I'm using the 1.3.2 version of the package with the following variables.
vars:
id-columns: ('anonymous_id', 'email')
schemas-to-include: ('id_stitching')
tables-to-include: ('id_mapping')
I ran the command
dbt run --full-refresh --select queries edges check_edges
Here is what the queries table looks like after it
SELECT DISTINCT EMAIL::TEXT AS node_a, 'EMAIL' AS node_a_label, ANONYMOUS_ID::TEXT AS node_b, 'ANONYMOUS_ID' AS node_b_label FROM DEV.ID_STITCHING.ID_MAPPING WHERE COALESCE(EMAIL::TEXT, '') != '' AND COALESCE(ANONYMOUS_ID::TEXT, '') != ''
Here is the output of the edges table
RUDDER_ID, ORIGINAL_RUDDER_ID, NODE_A, NODE_A_LABEL, NODE_B, NODE_B_LABEL, NODE_TIMESTAMP
1, 1, abc@gmail.com, EMAIL, 1, ANONYMOUS_ID, 2023-12-02 07:14:25.834 +0000
2, 2, a@gmail.com, EMAIL, 1, ANONYMOUS_ID, 2023-12-02 07:14:25.834 +0000
3, 3, null, EMAIL, 1, ANONYMOUS_ID, 2023-12-02 07:14:25.834 +0000
4, 4, a@gmail.com, EMAIL, 2, ANONYMOUS_ID, 2023-12-02 07:14:25.834 +0000
5, 5, b@gmail.com, EMAIL, 3, ANONYMOUS_ID, 2023-12-02 07:14:25.834 +0000
6, 6, null, EMAIL, 3, ANONYMOUS_ID, 2023-12-02 07:14:25.834 +0000
7, 7, c@gmail.com, EMAIL, 4, ANONYMOUS_ID, 2023-12-02 07:14:25.834 +0000
check_edges says consolidation_needed = false, so this it the final output.
As can be seen above, no ids were stitched together. Is something wrong with my configs or is this use case not the right one for this package?millions-activity-52391
12/02/2023, 7:22 AMfuture-caravan-11179
12/02/2023, 7:59 AMfuture-caravan-11179
12/02/2023, 7:59 AMgorgeous-continent-22485
12/02/2023, 3:21 PMgorgeous-continent-22485
12/02/2023, 5:11 PMfuture-caravan-11179
12/02/2023, 6:12 PMgorgeous-continent-22485
12/02/2023, 8:13 PMfuture-caravan-11179
12/03/2023, 8:47 AMfuture-caravan-11179
12/03/2023, 10:32 AMfuture-caravan-11179
12/03/2023, 10:32 AMgorgeous-continent-22485
12/03/2023, 11:42 AMgorgeous-continent-22485
12/03/2023, 11:42 AMfuture-caravan-11179
12/03/2023, 11:51 AMearly-table-25049
12/05/2023, 4:58 AMedges model, however it did not work in my case.
My initial thoughts on why this did not work is that the package doesn't seem to be considering bi-directional edges while computing the connected componentsfuture-caravan-11179
12/05/2023, 7:20 AMchilly-television-36470
12/06/2023, 12:39 AMfuture-caravan-11179
12/06/2023, 8:36 AMgorgeous-continent-22485
12/06/2023, 8:35 PMfuture-caravan-11179
12/06/2023, 8:38 PMfuture-caravan-11179
12/06/2023, 8:39 PMfuture-caravan-11179
12/06/2023, 8:39 PMfuture-caravan-11179
12/06/2023, 9:39 PMWITH RECURSIVE
CTE_1 AS (
(SELECT 1 AS iteration UNION ALL SELECT 1 AS iteration)
UNION ALL
SELECT iteration + 1 AS iteration FROM CTE_1 WHERE iteration < 3
)
SELECT iteration FROM CTE_1
ORDER BY 1 ASCfuture-caravan-11179
12/06/2023, 9:40 PMfuture-caravan-11179
12/06/2023, 9:41 PMCREATE TABLE some_schema.user_aliases as
WITH RECURSIVE
edges as (
select
anonymous_id as a,
coalesce(email, anonymous_id) as b
from page_visits
union all
select
contat_id as a,
email as b
from hubspot_contacts -- extending with Hubspot
union all
select
customer_id as a,
email as b
from stripe_customers -- extending with Stripe
),
bidirectional as (
select a,
b
from edges
union all
select b as a,
a as b
from edges
),
walks AS (
SELECT
a as a,
a as b,
1 as depth
FROM bidirectional
UNION
SELECT w.a,
e.b,
depth + 1 as depth
FROM walks w
JOIN bidirectional e ON w.b = e.a
and not (
e.a = w.a
and e.b = w.b
)
and not (
e.b = w.a
and e.a = w.b
)
-- Termination condition
where depth < 10
)
select
min(b) merged_id,
a as alias
from walks
group by 2gorgeous-continent-22485
12/06/2023, 9:47 PMfuture-caravan-11179
12/07/2023, 7:43 AM