Slide 18
Slide 18 text
© ZOZO, Inc.
18
後続データマート調査ツール導入に至るまで
● 後続データマート・後続データマートの参照者の洗い出しが大変
WITH table_jobs_meta AS (
SELECT
referenced_tables.dataset_id as referenced_table_dataset_id
,referenced_tables.table_id as referenced_table_table_id
,destination_table.dataset_id as destination_table_dataset_id
,destination_table.table_id as destination_table_table_id
FROM `region-us`.INFORMATION_SCHEMA.JOBS_BY_ORGANIZATION
JOIN UNNEST(referenced_tables) AS referenced_tables
WHERE DATE(creation_time, "Asia/Tokyo") >= DATE_SUB(CURRENT_DATE("Asia/Tokyo"), INTERVAL 90 DAY)
AND DATE(creation_time, "Asia/Tokyo") <= DATE_SUB(CURRENT_DATE("Asia/Tokyo"), INTERVAL 1 DAY)
)
,nest1 AS (
SELECT DISTINCT
"nest1" AS nest_level
,destination_table_dataset_id
,destination_table_table_id
FROM table_jobs_meta
WHERE referenced_table_table_id = 'SOME_TABLE'
AND (referenced_table_dataset_id, referenced_table_table_id) != (destination_table_dataset_id, destination_table_table_id) --自己参照除外
)
,nest2 AS (
SELECT DISTINCT
"nest2" AS nest_level
,destination_table_dataset_id
,destination_table_table_id
FROM table_jobs_meta
WHERE (referenced_table_dataset_id, referenced_table_table_id) IN (SELECT (T1.destination_table_dataset_id, T1.destination_table_table_id) FROM nest1 AS T1)
AND (referenced_table_dataset_id, referenced_table_table_id) != (destination_table_dataset_id, destination_table_table_id) --自己参照除外
AND (destination_table_dataset_id, destination_table_table_id) NOT IN (SELECT (T1.destination_table_dataset_id, T1.destination_table_table_id) FROM nest1 AS T1)
),
nest3 AS
... 後続データマート調査クエリの一部(JOBS ビューから取得)