Skip to content

Pull country from metrics in quick_suggest ping #7508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

curtismorales
Copy link
Contributor

@curtismorales curtismorales commented May 23, 2025

Description

This PR changes tables that are directly downstream of the quick_suggest tables to pull country from metrics rather than from metadata, in accordance with a change to the ping in Firefox 140.

I still need to update the tests, so I'm leaving this as a draft for now.

Related Tickets & Documents

Reviewer, please follow this checklist

@dataops-ci-bot

This comment has been minimized.

@dataops-ci-bot

This comment has been minimized.

@curtismorales curtismorales marked this pull request as ready for review July 1, 2025 23:47
@curtismorales curtismorales requested review from a team, whd and jasonthomas as code owners July 1, 2025 23:47
@dataops-ci-bot

This comment has been minimized.

@dataops-ci-bot

This comment has been minimized.

@dataops-ci-bot

This comment has been minimized.

@dataops-ci-bot

This comment has been minimized.

@dataops-ci-bot

This comment has been minimized.

@dataops-ci-bot

This comment has been minimized.

@curtismorales curtismorales requested a review from alekhyamoz July 9, 2025 20:12
@curtismorales curtismorales requested a review from a team as a code owner July 9, 2025 20:16
@dataops-ci-bot

This comment has been minimized.

@dataops-ci-bot

This comment has been minimized.

@dataops-ci-bot

This comment has been minimized.

@dataops-ci-bot

This comment has been minimized.

@dataops-ci-bot
Copy link

Integration report for "Merge branch 'main' into AD-869-update-suggest-derived-tables"

sql.diff

Click to expand!
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/contextual_services_derived/event_aggregates_suggest_v1/query.sql /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/contextual_services_derived/event_aggregates_suggest_v1/query.sql
--- /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/contextual_services_derived/event_aggregates_suggest_v1/query.sql	2025-08-07 21:17:07.000000000 +0000
+++ /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/contextual_services_derived/event_aggregates_suggest_v1/query.sql	2025-08-07 21:11:29.000000000 +0000
@@ -14,7 +14,14 @@
     metrics.uuid.quick_suggest_context_id AS context_id,
     DATE(submission_timestamp) AS submission_date,
     'desktop' AS form_factor,
-    normalized_country_code AS country,
+    -- As of Firefox 140, the quick_suggest ping is sent via OHTTP and now
+    -- receives geo information from the client rather than from Glean ingestion's
+    -- IP geolocation. We no longer send subdivision, only country.
+    IF(
+      SAFE_CAST(metadata.user_agent.version AS INT64) >= 140,
+      metrics.string.quick_suggest_country,
+      normalized_country_code
+    ) AS country,
     LOWER(metrics.string.quick_suggest_advertiser) AS advertiser,
     SPLIT(metadata.user_agent.os, ' ')[SAFE_OFFSET(0)] AS normalized_os,
     client_info.app_channel AS release_channel,
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/contextual_services_derived/event_aggregates_v1/query.sql /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/contextual_services_derived/event_aggregates_v1/query.sql
--- /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/contextual_services_derived/event_aggregates_v1/query.sql	2025-08-07 21:17:07.000000000 +0000
+++ /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/contextual_services_derived/event_aggregates_v1/query.sql	2025-08-07 21:11:29.000000000 +0000
@@ -20,8 +20,19 @@
       "impression"
     ) AS event_type,
     'desktop' AS form_factor,
-    normalized_country_code AS country,
-    metadata.geo.subdivision1 AS subdivision1,
+    -- As of Firefox 140, the quick_suggest ping is sent via OHTTP and now
+    -- receives geo information from the client rather than from Glean ingestion's
+    -- IP geolocation. We no longer send subdivision, only country.
+    IF(
+      SAFE_CAST(metadata.user_agent.version AS INT64) >= 140,
+      metrics.string.quick_suggest_country,
+      normalized_country_code
+    ) AS country,
+    IF(
+      SAFE_CAST(metadata.user_agent.version AS INT64) >= 140,
+      CAST(NULL AS STRING),
+      metadata.geo.subdivision1
+    ) AS subdivision1,
     metrics.string.quick_suggest_advertiser AS advertiser,
     client_info.app_channel AS release_channel,
     metrics.quantity.quick_suggest_position AS position,
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/contextual_services_derived/request_payload_suggest_v2/query.sql /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/contextual_services_derived/request_payload_suggest_v2/query.sql
--- /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/contextual_services_derived/request_payload_suggest_v2/query.sql	2025-08-07 21:17:07.000000000 +0000
+++ /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/contextual_services_derived/request_payload_suggest_v2/query.sql	2025-08-07 21:11:29.000000000 +0000
@@ -18,8 +18,19 @@
       "click",
       "impression"
     ) AS interaction_type,
-    metadata.geo.country AS country_code,
-    metadata.geo.subdivision1 AS region_code,
+    -- As of Firefox 140, the quick_suggest ping is sent via OHTTP and now
+    -- receives geo information from the client rather than from Glean ingestion's
+    -- IP geolocation. We no longer send subdivision, only country.
+    IF(
+      SAFE_CAST(metadata.user_agent.version AS INT64) >= 140,
+      metrics.string.quick_suggest_country,
+      metadata.geo.country
+    ) AS country_code,
+    IF(
+      SAFE_CAST(metadata.user_agent.version AS INT64) >= 140,
+      CAST(NULL AS STRING),
+      metadata.geo.subdivision1
+    ) AS region_code,
     metadata.user_agent.os AS os_family,
     metadata.user_agent.version AS product_version,
   FROM
diff -bur --no-dereference --new-file /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/search_terms_derived/suggest_impression_sanitized_v3/query.sql /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/search_terms_derived/suggest_impression_sanitized_v3/query.sql
--- /tmp/workspace/main-generated-sql/sql/moz-fx-data-shared-prod/search_terms_derived/suggest_impression_sanitized_v3/query.sql	2025-08-07 21:17:07.000000000 +0000
+++ /tmp/workspace/generated-sql/sql/moz-fx-data-shared-prod/search_terms_derived/suggest_impression_sanitized_v3/query.sql	2025-08-07 21:11:30.000000000 +0000
@@ -45,8 +45,16 @@
     sample_id,
     metrics.boolean.quick_suggest_is_clicked AS is_clicked,
     client_info.locale AS locale,
-    metadata.geo.country,
-    metadata.geo.subdivision1 AS region,
+    IF(
+      SAFE_CAST(metadata.user_agent.version AS INT64) >= 140,
+      metrics.string.quick_suggest_country,
+      metadata.geo.country
+    ) AS country,
+    IF(
+      SAFE_CAST(metadata.user_agent.version AS INT64) >= 140,
+      CAST(NULL AS STRING),
+      metadata.geo.subdivision1
+    ) AS region,
     normalized_os,
     normalized_os_version,
     normalized_channel,

Link to full diff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants