Extract search counts from histogram in telemetry search metrics view

This commit is contained in:
Anna Scholtz 2021-03-19 16:04:31 -07:00
Родитель 18ca51fcef
Коммит 16b17f6891
4 изменённых файлов: 34 добавлений и 9 удалений

Просмотреть файл

@ -87,7 +87,8 @@ IF
) )
) AS nested_counts ) AS nested_counts
FROM FROM
`moz-fx-data-shared-prod.org_mozilla_fenix_live.metrics_v1`, `moz-fx-data-shared-prod.org_mozilla_fenix_live.metrics_v1`
LEFT JOIN
UNNEST(ping_info.experiments) AS experiment UNNEST(ping_info.experiments) AS experiment
WHERE WHERE
-- Limit the amount of data the materialized view is going to backfill when created. -- Limit the amount of data the materialized view is going to backfill when created.

Просмотреть файл

@ -87,7 +87,8 @@ IF
) )
) AS nested_counts ) AS nested_counts
FROM FROM
`moz-fx-data-shared-prod.org_mozilla_firefox_beta_live.metrics_v1`, `moz-fx-data-shared-prod.org_mozilla_firefox_beta_live.metrics_v1`
LEFT JOIN
UNNEST(ping_info.experiments) AS experiment UNNEST(ping_info.experiments) AS experiment
WHERE WHERE
-- Limit the amount of data the materialized view is going to backfill when created. -- Limit the amount of data the materialized view is going to backfill when created.

Просмотреть файл

@ -87,7 +87,8 @@ IF
) )
) AS nested_counts ) AS nested_counts
FROM FROM
`moz-fx-data-shared-prod.org_mozilla_firefox_live.metrics_v1`, `moz-fx-data-shared-prod.org_mozilla_firefox_live.metrics_v1`
LEFT JOIN
UNNEST(ping_info.experiments) AS experiment UNNEST(ping_info.experiments) AS experiment
WHERE WHERE
-- Limit the amount of data the materialized view is going to backfill when created. -- Limit the amount of data the materialized view is going to backfill when created.

Просмотреть файл

@ -69,11 +69,32 @@ IF
-- (3) -- (3)
REGEXP_REPLACE( REGEXP_REPLACE(
-- (2) -- (2)
TO_JSON_STRING( CONCAT(
REGEXP_EXTRACT_ALL( TO_JSON_STRING(
-- (1) ARRAY_CONCAT(
TO_JSON_STRING(payload.keyed_histograms.search_counts), -- extract sum from histogram
'"value":([^,}]+)' -- acount for compact and JSON histograms
REGEXP_EXTRACT_ALL(
-- (1)
TO_JSON_STRING(payload.keyed_histograms.search_counts),
r'\\"sum\\":([^},]+)'
),
REGEXP_EXTRACT_ALL(
-- (1)
TO_JSON_STRING(payload.keyed_histograms.search_counts),
r'"value":"(\d+)"'
),
REGEXP_EXTRACT_ALL(
-- (1)
TO_JSON_STRING(payload.keyed_histograms.search_counts),
r'"value":"\d+;(\d+);'
),
REGEXP_EXTRACT_ALL(
-- (1)
TO_JSON_STRING(payload.keyed_histograms.search_counts),
r'"value":"(\d+),\d+"'
)
)
) )
), ),
r'"([^"]+)"', r'"([^"]+)"',
@ -83,7 +104,8 @@ IF
) )
) AS nested_counts ) AS nested_counts
FROM FROM
`moz-fx-data-shared-prod.telemetry_live.main_v4`, `moz-fx-data-shared-prod.telemetry_live.main_v4`
LEFT JOIN
UNNEST(environment.experiments) AS experiment UNNEST(environment.experiments) AS experiment
WHERE WHERE
-- Limit the amount of data the materialized view is going to backfill when created. -- Limit the amount of data the materialized view is going to backfill when created.