Skip to content

Commit bce6c8f

Browse files
authored
[AIMOD-1383] Engagement GCS Artifacts for merino use daily-country propensity (#9702)
* saves a daily snapshot of propensity * newtab_merino_propensity_v2 * trying to minimize diff with v1 * added country * add new v4 instead of using v3 for merino data export * use country specific propensities * change type * closer to v3 * clashing withv v3? * Use propensity v2 for Merino newtab extract * added IT region
1 parent 951a5eb commit bce6c8f

3 files changed

Lines changed: 41 additions & 11 deletions

File tree

sql/moz-fx-data-shared-prod/telemetry_derived/newtab_merino_extract_v3/metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
friendly_name: Newtab Merino Extract
22
description: |-
3-
Aggregated Newtab events for Merino recommendations.
3+
Aggregated Newtab events for Merino recommendations using v2 propensity weights.
44
See https://mozilla-hub.atlassian.net/browse/MC-1256
55
owners:
66
- mmiermans@mozilla.com

sql/moz-fx-data-shared-prod/telemetry_derived/newtab_merino_extract_v3/query.sql

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,30 +69,60 @@ raw_grouped_totals AS (
6969
format,
7070
section_position
7171
),
72+
propensity_weights AS (
73+
SELECT
74+
country,
75+
position,
76+
tile_format,
77+
weight
78+
FROM
79+
`moz-fx-data-shared-prod.telemetry_derived.newtab_merino_propensity_v2`
80+
WHERE
81+
layout = 'SECTION_GRID'
82+
AND section_position IS NULL
83+
AND snapshot_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 14 DAY)
84+
QUALIFY
85+
snapshot_date = MAX(snapshot_date) OVER ()
86+
),
7287
/* Separate and adjust section events */
7388
section_events AS (
7489
SELECT
7590
rw.normalized_country_code,
7691
rw.corpus_item_id,
7792
rw.raw_impression_count,
7893
-- apply propensity scaling to impressions only
94+
-- prefer exact-format weights, then fall back to 'any' format weights
7995
rw.raw_impression_count / COALESCE(
80-
wt_exact.weight,
81-
wt_any.weight,
96+
wt_country_exact.weight,
97+
wt_global_exact.weight,
98+
wt_country_any.weight,
99+
wt_global_any.weight,
82100
1.0
83101
) AS adjusted_impression_count,
84102
rw.report_count,
85103
rw.click_count
86104
FROM
87105
raw_grouped_totals rw
88106
LEFT JOIN
89-
`moz-fx-data-shared-prod.telemetry_derived.newtab_merino_propensity_v1` wt_exact
90-
ON SAFE_CAST(wt_exact.position AS INT64) = rw.position
91-
AND wt_exact.tile_format = rw.format
107+
propensity_weights wt_country_exact
108+
ON wt_country_exact.country = rw.normalized_country_code
109+
AND SAFE_CAST(wt_country_exact.position AS INT64) = rw.position
110+
AND wt_country_exact.tile_format = rw.format
111+
LEFT JOIN
112+
propensity_weights wt_country_any
113+
ON wt_country_any.country = rw.normalized_country_code
114+
AND SAFE_CAST(wt_country_any.position AS INT64) = rw.position
115+
AND wt_country_any.tile_format = 'any'
116+
LEFT JOIN
117+
propensity_weights wt_global_exact
118+
ON wt_global_exact.country IS NULL
119+
AND SAFE_CAST(wt_global_exact.position AS INT64) = rw.position
120+
AND wt_global_exact.tile_format = rw.format
92121
LEFT JOIN
93-
`moz-fx-data-shared-prod.telemetry_derived.newtab_merino_propensity_v1` wt_any
94-
ON SAFE_CAST(wt_any.position AS INT64) = rw.position
95-
AND wt_any.tile_format = 'any'
122+
propensity_weights wt_global_any
123+
ON wt_global_any.country IS NULL
124+
AND SAFE_CAST(wt_global_any.position AS INT64) = rw.position
125+
AND wt_global_any.tile_format = 'any'
96126
WHERE
97127
rw.section_position IS NOT NULL
98128
),

sql/moz-fx-data-shared-prod/telemetry_derived/newtab_merino_priors_v1/query.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ target_regions AS (
1515
SELECT
1616
region
1717
FROM
18-
UNNEST(['US', 'CA', 'DE', 'CH', 'AT', 'GB', 'IE', 'BE', 'PL', 'FR', 'ES']) AS region
18+
UNNEST(['US', 'CA', 'DE', 'CH', 'AT', 'GB', 'IE', 'BE', 'PL', 'FR', 'ES', 'IT']) AS region
1919
),
2020
corpus_items AS (
2121
SELECT DISTINCT
@@ -231,7 +231,7 @@ SELECT
231231
FROM
232232
per_region_final
233233
WHERE
234-
region IN ('US', 'CA', 'DE', 'CH', 'AT', 'GB', 'IE', 'BE', 'PL', 'FR', 'ES')
234+
region IN ('US', 'CA', 'DE', 'CH', 'AT', 'GB', 'IE', 'BE', 'PL', 'FR', 'ES', 'IT')
235235
UNION ALL
236236
SELECT
237237
region,

0 commit comments

Comments
 (0)