アウトプット#
ここからは、今回の例によって出力されたテーブル群を詳細に見ていく。Unification Output で紹介した説明より詳しいものとなっており、各テーブルの各カラムの意味まで言及している。
結果を格納するデータベース#
unification_ex1.yml で定義された name:
の値を用いた cdp_unification_${name}
のデータベースが作成され、その中に結果が格納される。今回の例では cdp_unification_test_id_unification_ex1
である。
name: test_id_unification_ex1 # Unification Name
keys:
- name: td_client_id
- name: td_global_id
tables:
- database: test_id_unification_ex1
table: ex1_site_aaa
key_columns:
- {column: td_client_id, key: td_client_id}
- {column: td_global_id, key: td_global_id}

Fig. 26 cdp_unification_test_id_unification_ex1 Table#
結果を活用するテーブル群#
master_table#
今回の例では master_table_ex1 となる。
master_tables:
- name: master_table_ex1
canonical_id: unified_cookie_id
attributes:
- name: td_client_id
invalid_texts: ['']
array_elements: 5
source_columns:
- {table: site_aaa, order: first, order_by: td_client_id, priority: 1}
- {table: site_xxx, order: first, order_by: td_client_id, priority: 2}
- {table: site_yyy, order: first, order_by: td_client_id, priority: 3}
- {table: site_zzz, order: first, order_by: td_client_id, priority: 4}
- name: td_global_id
valid_regexp: "3rd_*"
invalid_texts: ['']
source_columns:
- {table: site_aaa, order: last, order_by: time, priority: 1}
- {table: site_xxx, order: last, order_by: time, priority: 1}
- {table: site_yyy, order: last, order_by: time, priority: 1}
- {table: site_zzz, order: last, order_by: time, priority: 1}
master_tables:
において name:
で指定された値のテーブルが出力される。オーディエンススタジオの Master Segment において、master_table として活用するものである。以下が今回の結果である。
結果#
unified_cookie_id |
td_client_id |
td_global_id |
time |
---|---|---|---|
tRf8bJZ_0EC1 |
[“aaa_001”, “aaa_001”, “aaa_001”, “aaa_001”, “aaa_002”] |
3rd_018 |
1691675802 |
canonical_id ごとにレコードが生成されるので、今回のケースでは1行のみのレコードとなる。time カラムは単純にテーブルが作成された時間である。

Fig. 27 yml の記述と master_table の対応#
canonical_id の他に、attibutes:
指定したカラムの値が格納される。td_client_id は、最大5つまでを source_tables:
で決めたテーブルの順番とレコード順序でピックアップするが、今回の結果のように値が重複してしまうこともあるので注意。
enriched_ Table#
今回の例では enriched_site_aaa (xxx,yyy,zzz) となる。
tables:
- database: test_id_unification_ex1
table: site_aaa
key_columns:
- {column: td_client_id, key: td_client_id}
- {column: td_global_id, key: td_global_id}
- database: test_id_unification_ex1
table: site_xxx
key_columns:
- {column: td_client_id, key: td_client_id}
- {column: td_global_id, key: td_global_id}
- database: test_id_unification_ex1
table: site_yyy
key_columns:
- {column: td_client_id, key: td_client_id}
- {column: td_global_id, key: td_global_id}
- database: test_id_unification_ex1
table: site_zzz
key_columns:
- {column: td_client_id, key: td_client_id}
- {column: td_global_id, key: td_global_id}
enriched_${source_table_name} のテーブルが出力される (今回は4つ)。これらは Master Segment において aattribute_table および behavior_table として活用するものである。
結果#
enriched_site_aaa テーブルのみを示す。
time |
site |
td_client_id |
td_global_id |
unified_cookie_id |
---|---|---|---|---|
1672876800 |
aaa.jp |
aaa_001 |
3rd_001 |
tRf8bJZ_0EC1 |
1673740800 |
aaa.jp |
aaa_001 |
3rd_002 |
tRf8bJZ_0EC1 |
1674604800 |
aaa.jp |
aaa_001 |
3rd_003 |
tRf8bJZ_0EC1 |
1675555200 |
aaa.jp |
aaa_001 |
3rd_004 |
tRf8bJZ_0EC1 |
1676419200 |
aaa.jp |
|||
1677283200 |
aaa.jp |
|||
1677974400 |
aaa.jp |
|||
1678838400 |
aaa.jp |
|||
1679702400 |
aaa.jp |
aaa_002 |
3rd_009 |
tRf8bJZ_0EC1 |
1680652800 |
aaa.jp |
aaa_002 |
3rd_010 |
tRf8bJZ_0EC1 |
1681516800 |
aaa.jp |
|||
1682380800 |
aaa.jp |
|||
1683244800 |
aaa.jp |
aaa_003 |
3rd_013 |
tRf8bJZ_0EC1 |
1684108800 |
aaa.jp |
aaa_003 |
3rd_014 |
tRf8bJZ_0EC1 |
1684972800 |
aaa.jp |
aaa_003 |
3rd_015 |
tRf8bJZ_0EC1 |
1685923200 |
aaa.jp |
aaa_003 |
3rd_016 |
tRf8bJZ_0EC1 |
1686787200 |
aaa.jp |
|||
1687651200 |
aaa.jp |

Fig. 28 yml の記述と enriched_ Table の対応#
Unification がうまくいったかを確認するためのテーブル群#
source_key_stats Table#
今回の例では unified_cookie_id_source_key_stats となる。
ソーステーブルの統計情報 (各 key のユニーク数など) を出力したテーブル。total_distinct カラムのみ、unified_cookie_id_graph_unify_loop_0
テーブルから計算している。
実行毎に追記されるテーブルなので、最新のレコードを取得するためには以下のクエリを実行する:
SELECT *
FROM (
SELECT *, RANK()OVER(ORDER BY time DESC) AS id
FROM unified_cookie_id_source_key_stats
)
WHERE id = 1
ORDER BY from_table
結果#
※ id カラムは上記の SQL によって付加されたものである。
from_table |
total_distinct |
distinct_td_client_id |
distinct_td_global_id |
time |
id |
---|---|---|---|---|---|
* |
16 |
16 |
18 |
1691675802 |
1 |
site_aaa |
12 |
3 |
10 |
1691675802 |
1 |
site_xxx |
11 |
4 |
8 |
1691675802 |
1 |
site_yyy |
12 |
5 |
7 |
1691675802 |
1 |
site_zzz |
13 |
4 |
9 |
1691675802 |
1 |

Fig. 29 source_key_stats Table の解説#
result_key_stats Table#
今回の例では unified_cookie_id_result_key_stats となる。
ID Unification の結果、それぞれのテーブルでいくつの canonical_id (ユニークな個人) が生成されたか、などの統計情報を記録。実行毎に追記されるテーブルなので、最新のレコードを取得するためには以下のクエリを実行する:
SELECT *
FROM (
SELECT *, RANK()OVER(ORDER BY time DESC) AS id
FROM unified_cookie_id_result_key_stats
)
WHERE id = 1
ORDER BY from_table
結果#
※ id カラムは上記の SQL によって付加されたものである。
from_table |
total_distinct |
distinct_with_td_client_id |
distinct_with_td_global_id |
histogram_td_client_id |
histogram_td_global_id |
time |
id |
---|---|---|---|---|---|---|---|
* |
1 |
1 |
1 |
16:1 |
18:1 |
1691675802 |
1 |
site_aaa |
1 |
1 |
1 |
16:1 |
18:1 |
1691675802 |
1 |
site_xxx |
1 |
1 |
1 |
16:1 |
18:1 |
1691675802 |
1 |
site_yyy |
1 |
1 |
1 |
16:1 |
18:1 |
1691675802 |
1 |
site_zzz |
1 |
1 |
1 |
16:1 |
18:1 |
1691675802 |
1 |

Fig. 30 result_key_stats Table の解説#
from_table Column#
どのソーステーブルの統計情報を計算したかの情報。全てのテーブルをマージした "*"
も入っている。
total_distinct Column#
全体 ( "*"
の場合)、またはそのテーブルが持つ canonical_id のユニーク数。
distinct_with_td_client_id Column#
1つ以上の td_client_id が含まれている canonical_id の数。言い換えると、全 canonical_id から、td_client_id を利用して縫い合わせが行われなかった canonical_id を除いたもの。
distinct_with_td_global_id Column#
1つ以上の td_global_id が含まれている canonical_id の数。言い換えると、全 canonical_id から、td_global_id を利用して縫い合わせが行われなかった canonical_id を除いたもの。
histogram_td_client_id Column#
以下のステップで計算されるヒストグラムデータである。このカラムは SQL にて展開してヒストグラムを描き、縫い合わせの状況を理解するのに役立つ。
1つ1つの canonical_id に対して、以下を求める。
いくつの td_client_id が 1 つの canonical_id になったか
今回の例では「16個の td_client_id が 1つの canonical_id になった」
これを全ての canonical_id で集計することによって例えば以下の結果を得る:
1個の td_client_id が canonical_id になったものが10個
2個の td_client_id が canonical_id になったものが5個
3個の td_client_id が canonical_id になったものが8個
…
これらを histogram_td_client_id カラムの中で “1:10,2:5,3:8,..” と記述する。
今回の例では canonical_id が1つしかなく、16個の td_client_id が canonical_id になったものが1つあるだけなので “16:1” となっている。
histogram_td_global_id Column#
histogram_td_client_id と同様、N個の td_global_id が canonical_id になったものがM個ある (N:M) を N=1,2,…でカンマ区切りで並べたものになる。
今回の例では canonical_id が1つしかなく、18個の td_global_id が canonical_id になったものが1つあるだけなので “18:1” となっている。
Unification Algorithm の過程で生成されるテーブル群#
以下のテーブル群は、WF が内部的に使用するテーブル群であるが、一部収束判定に使われるものなどがある。
graph_unify_loop_N Table#
今回の例では unified_cookie_id_graph_unify_loop_0 (1,2,3,4) となる。
アルゴリズムの紹介のところで何度も登場した、N 回目のループにおける graph の状態を表すテーブルである。 最後のループ回は、名前が異なる (graph Table) ため存在しない。
follower_id, leader_id Column#
follower、leader の key の値。
follower_ns, leader_ns Column#
follower、leader がどの key かを示す。merge_by_keys:
で列挙された順番に 1,2,… の値を持つ。
今回の例では td_client_id なら1、td_global_id なら2となる。
follower_first_seen_at, follower_last_seen_at Column#
follower のkey の値がソーステーブルの中で (timeカラムの意味で) 初めて、または最後に登場した時間を記録する。
follower_source_table_ids Column#
follower の key の値が含まれているソーステーブルの id を配列として列挙。id がどのソーステーブルを意味しているかは tables Table (今回の例では unified_cookie_id_tables) を参照する。
follower_last_processed_at Column#
そのループの中で、follower が処理された最新の時間。
graph Table#
今回の例では unified_cookie_id_graph。指定された最後のループ回の graph の状態を表すテーブル。
canonical_id と key をマッピングするためのテーブル群#
lookup Table#
今回の例では unified_cookie_id_lookup となる。 全ての key の値が1行ずつになったテーブルであり、その key が持つ canonical_id が参照できるテーブルである。つまり、 key を指定する事でそれの canonical_id を lookup することができるテーブルである。master_table や エンリッチテーブルの作成に使われる。

Fig. 31 lookup Table の解説#
結果#
canonical_id |
id |
id_key_type |
canonical_id_first_seen_at |
canonical_id_last_seen_at |
id_first_seen_at |
id_last_seen_at |
id_source_table_ids |
id_last_processed_at |
time |
---|---|---|---|---|---|---|---|---|---|
tRf8bJZ_0EC1 |
3rd_016 |
2 |
1672876800 |
1687651200 |
1685923200 |
1685923200 |
[5, 6] |
1691675863 |
1691675802 |
tRf8bJZ_0EC1 |
aaa_001 |
1 |
1672876800 |
1687651200 |
1672876800 |
1675555200 |
[5] |
1691675815 |
1691675802 |
tRf8bJZ_0EC1 |
yyy_003 |
1 |
1672876800 |
1687651200 |
1680652800 |
1681516800 |
[7] |
1691675851 |
1691675802 |
tRf8bJZ_0EC1 |
3rd_010 |
2 |
1672876800 |
1687651200 |
1680652800 |
1680652800 |
[7, 5] |
1691675851 |
1691675802 |
以下で紹介する以外のカラムの意味は unified_cookie_id_graph_unify_loop_0 テーブルとほぼ同じなのでそちらを参照のこと。
id_key_type Column#
id がどの key のものであるか (今回の例では td_client_id、td_global_id) を key_type (番号) で格納。 key_type と key_name のマッピングは keys Table (今回の例では unified_cookie_id_keys) を参照。
id_source_table_ids Column#
id が含まれるソーステーブルを id_source_table_ids に格納。 各 table_id と table_name のマッピングは tables Table (今回の例では unified_cookie_id_tables) を参照。