DENG-2095 Update accounts_backend.users_services_daily_v1 (#5116)

This commit is contained in:
akkomar 2024-02-26 19:35:59 +01:00 коммит произвёл GitHub
Родитель 7d28bb1785
Коммит 406098188c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 8 добавлений и 14 удалений

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

@ -18,7 +18,7 @@ CREATE TEMP FUNCTION udf_contains_tier1_country(x ANY TYPE) AS ( --
WITH fxa_events AS ( WITH fxa_events AS (
SELECT SELECT
submission_timestamp, submission_timestamp,
metrics.string.account_user_id_sha256 AS user_id, metrics.string.account_user_id_sha256 AS user_id_sha256,
IF( IF(
metrics.string.relying_party_oauth_client_id = '', metrics.string.relying_party_oauth_client_id = '',
metrics.string.relying_party_service, metrics.string.relying_party_service,
@ -29,7 +29,6 @@ WITH fxa_events AS (
metrics.string.event_name AS event_name, metrics.string.event_name AS event_name,
-- `access_token_checked` events are triggered on traffic from RP backend services and don't have client's geo data -- `access_token_checked` events are triggered on traffic from RP backend services and don't have client's geo data
IF(metrics.string.event_name != 'access_token_checked', metadata.geo.country, NULL) AS country, IF(metrics.string.event_name != 'access_token_checked', metadata.geo.country, NULL) AS country,
client_info.locale AS language,
metrics.string.utm_term AS utm_term, metrics.string.utm_term AS utm_term,
metrics.string.utm_medium AS utm_medium, metrics.string.utm_medium AS utm_medium,
metrics.string.utm_source AS utm_source, metrics.string.utm_source AS utm_source,
@ -52,10 +51,9 @@ WITH fxa_events AS (
windowed AS ( windowed AS (
SELECT SELECT
submission_timestamp, submission_timestamp,
user_id, user_id_sha256,
service, service,
udf.mode_last(ARRAY_AGG(country) OVER w1) AS country, udf.mode_last(ARRAY_AGG(country) OVER w1) AS country,
udf.mode_last(ARRAY_AGG(LANGUAGE) OVER w1) AS language,
udf_contains_tier1_country(ARRAY_AGG(country) OVER w1) AS seen_in_tier1_country, udf_contains_tier1_country(ARRAY_AGG(country) OVER w1) AS seen_in_tier1_country,
LOGICAL_OR(event_name = 'reg_complete') OVER w1 AS registered, LOGICAL_OR(event_name = 'reg_complete') OVER w1 AS registered,
ARRAY_AGG(event_name) OVER w1 AS service_events, ARRAY_AGG(event_name) OVER w1 AS service_events,
@ -63,12 +61,12 @@ windowed AS (
fxa_events fxa_events
WHERE WHERE
DATE(submission_timestamp) = @submission_date DATE(submission_timestamp) = @submission_date
AND user_id != '' AND user_id_sha256 != ''
AND service != '' AND service != ''
QUALIFY QUALIFY
ROW_NUMBER() OVER ( ROW_NUMBER() OVER (
PARTITION BY PARTITION BY
user_id, user_id_sha256,
service, service,
DATE(submission_timestamp) DATE(submission_timestamp)
ORDER BY ORDER BY
@ -77,7 +75,7 @@ windowed AS (
WINDOW WINDOW
w1 AS ( w1 AS (
PARTITION BY PARTITION BY
user_id, user_id_sha256,
service, service,
DATE(submission_timestamp) DATE(submission_timestamp)
ORDER BY ORDER BY
@ -89,10 +87,9 @@ windowed AS (
) )
SELECT SELECT
DATE(@submission_date) AS submission_date, DATE(@submission_date) AS submission_date,
windowed.user_id, windowed.user_id_sha256,
oa.name AS service, oa.name AS service,
windowed.country, windowed.country,
windowed.language,
windowed.seen_in_tier1_country, windowed.seen_in_tier1_country,
windowed.registered, windowed.registered,
windowed.service_events, windowed.service_events,
@ -102,5 +99,5 @@ JOIN
`accounts_db.fxa_oauth_clients` AS oa `accounts_db.fxa_oauth_clients` AS oa
ON windowed.service = oa.id ON windowed.service = oa.id
WHERE WHERE
user_id IS NOT NULL user_id_sha256 IS NOT NULL
AND service IS NOT NULL AND service IS NOT NULL

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

@ -2,7 +2,7 @@ fields:
- name: submission_date - name: submission_date
type: DATE type: DATE
mode: NULLABLE mode: NULLABLE
- name: user_id - name: user_id_sha256
type: STRING type: STRING
mode: NULLABLE mode: NULLABLE
- name: service - name: service
@ -11,9 +11,6 @@ fields:
- name: country - name: country
type: STRING type: STRING
mode: NULLABLE mode: NULLABLE
- name: language
type: STRING
mode: NULLABLE
- name: seen_in_tier1_country - name: seen_in_tier1_country
type: BOOLEAN type: BOOLEAN
mode: NULLABLE mode: NULLABLE