From 8af0c2989c5d7bb2d1e77cc0f09ca3f4cbf4537e Mon Sep 17 00:00:00 2001 From: akkomar Date: Thu, 29 Feb 2024 16:52:34 +0100 Subject: [PATCH] Add estimate for number of devices to accounts_backend.users_services_last_seen_v1 (#5140) --- .../users_services_last_seen_v1/query.sql | 24 ++++++++++++------- .../users_services_last_seen_v1/schema.yaml | 4 ++++ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/sql/moz-fx-data-shared-prod/accounts_backend_derived/users_services_last_seen_v1/query.sql b/sql/moz-fx-data-shared-prod/accounts_backend_derived/users_services_last_seen_v1/query.sql index 92e14902f5..9ba2adf74c 100644 --- a/sql/moz-fx-data-shared-prod/accounts_backend_derived/users_services_last_seen_v1/query.sql +++ b/sql/moz-fx-data-shared-prod/accounts_backend_derived/users_services_last_seen_v1/query.sql @@ -1,16 +1,16 @@ WITH _current AS ( SELECT - * EXCEPT (submission_date, registered, seen_in_tier1_country), -- In this raw table, we capture the history of activity over the past - -- 28 days for each usage criterion as a single 64-bit integer. The - -- rightmost bit represents whether the user was active in the current day. + -- 28 days for each usage criterion as a single 64-bit integer. The + -- rightmost bit represents whether the user was active in the current day. CAST(TRUE AS INT64) AS days_seen_bits, - -- Record days on which the user was in a "Tier 1" country; - -- this allows a variant of country-segmented MAU where we can still count - -- a user that appeared in one of the target countries in the previous - -- 28 days even if the most recent "country" value is not in this set. + -- Record days on which the user was in a "Tier 1" country; + -- this allows a variant of country-segmented MAU where we can still count + -- a user that appeared in one of the target countries in the previous + -- 28 days even if the most recent "country" value is not in this set. CAST(seen_in_tier1_country AS INT64) AS days_seen_in_tier1_country_bits, CAST(registered AS INT64) AS days_registered_bits, + * EXCEPT (submission_date, registered, seen_in_tier1_country), FROM accounts_backend_derived.users_services_daily_v1 WHERE @@ -18,7 +18,15 @@ WITH _current AS ( ), _previous AS ( SELECT - * EXCEPT (submission_date) + days_seen_bits, + days_seen_in_tier1_country_bits, + days_registered_bits, + * EXCEPT ( + days_seen_bits, + days_seen_in_tier1_country_bits, + days_registered_bits, + submission_date + ) FROM accounts_backend_derived.users_services_last_seen_v1 WHERE diff --git a/sql/moz-fx-data-shared-prod/accounts_backend_derived/users_services_last_seen_v1/schema.yaml b/sql/moz-fx-data-shared-prod/accounts_backend_derived/users_services_last_seen_v1/schema.yaml index e33861fe0f..9bd78d17f7 100644 --- a/sql/moz-fx-data-shared-prod/accounts_backend_derived/users_services_last_seen_v1/schema.yaml +++ b/sql/moz-fx-data-shared-prod/accounts_backend_derived/users_services_last_seen_v1/schema.yaml @@ -26,3 +26,7 @@ fields: type: INTEGER description: | No. of days since registration event. +- name: user_agent_device_count + type: INTEGER + mode: NULLABLE + description: Number of devices associated with the user, per service, per day. Estimated from the number of unique user agent strings.