Skip to content

Commit

Permalink
Bug 1860814 - fix amo_prod__desktop_addons_by_client (#4481)
Browse files Browse the repository at this point in the history
* quick fix

* fix spread out groupby

* move out sourcetable query

---------

Co-authored-by: Frank Bertsch <[email protected]>
  • Loading branch information
2 people authored and irrationalagent committed Dec 11, 2023
1 parent 461cfb0 commit ae0b290
Showing 1 changed file with 74 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,27 @@ try {
}
""";

WITH per_client AS (
WITH filtered_main AS (
SELECT
submission_timestamp,
client_id,
sample_id,
payload.info.addons,
application.version,
normalized_country_code,
environment.settings.locale,
normalized_os
FROM
telemetry.main
WHERE
DATE(submission_timestamp) = @submission_date
AND client_id IS NOT NULL
),
per_clients_without_addons AS (
SELECT
DATE(submission_timestamp) AS submission_date,
client_id,
sample_id,
ARRAY_CONCAT_AGG(
-- As of 2020-07-17, we parse addon info from the payload.info.addons string
-- because it provides more complete information compared to environment.addons.active_addons
-- See https://bugzilla.mozilla.org/show_bug.cgi?id=1653499
-- Previous logic in https://github.com/mozilla/bigquery-etl/blob/55a429924beee3c31aca4fee0063d655f1d527f2/sql/amo_prod/desktop_addons_by_client_v1/query.sql
ARRAY(
SELECT AS STRUCT
decode_uri_component(REGEXP_EXTRACT(TRIM(addon), "(.+):")) AS id,
REGEXP_EXTRACT(TRIM(addon), ":(.+)") AS version
FROM
UNNEST(SPLIT(payload.info.addons, ",")) AS addon
)
ORDER BY
submission_timestamp
) AS addons,
-- We always want to take the most recent seen version per
-- https://bugzilla.mozilla.org/show_bug.cgi?id=1693308
ARRAY_AGG(
Expand All @@ -50,14 +51,67 @@ WITH per_client AS (
) AS locale,
mozfun.stats.mode_last(ARRAY_AGG(normalized_os ORDER BY submission_timestamp)) AS app_os,
FROM
telemetry.main
WHERE
DATE(submission_timestamp) = @submission_date
AND client_id IS NOT NULL
filtered_main
GROUP BY
submission_date,
sample_id,
client_id
),
per_clients_just_addons_base AS (
SELECT
DATE(submission_timestamp) AS submission_date,
client_id,
sample_id,
payload.info.addons
FROM
filtered_main
GROUP BY
submission_date,
client_id,
sample_id,
addons
),
per_clients_just_addons AS (
SELECT
submission_date,
client_id,
sample_id,
ARRAY_CONCAT_AGG(
-- As of 2020-07-17, we parse addon info from the payload.info.addons string
-- because it provides more complete information compared to environment.addons.active_addons
-- See https://bugzilla.mozilla.org/show_bug.cgi?id=1653499
-- Previous logic in https://github.com/mozilla/bigquery-etl/blob/55a429924beee3c31aca4fee0063d655f1d527f2/sql/amo_prod/desktop_addons_by_client_v1/query.sql
ARRAY(
SELECT AS STRUCT
decode_uri_component(REGEXP_EXTRACT(TRIM(addon), "(.+):")) AS id,
REGEXP_EXTRACT(TRIM(addon), ":(.+)") AS version
FROM
UNNEST(SPLIT(addons, ",")) AS addon
)
) AS addons
FROM
per_clients_just_addons_base
GROUP BY
submission_date,
sample_id,
client_id
),
per_client AS (
SELECT
submission_date,
client_id,
sample_id,
addons,
app_version,
country,
locale,
app_os,
FROM
per_clients_without_addons
INNER JOIN
per_clients_just_addons
USING
(submission_date, client_id, sample_id)
)
SELECT
* EXCEPT (addons),
Expand Down

0 comments on commit ae0b290

Please sign in to comment.