DENG-2095 Update accounts_backend.users_services_daily_v1 (#5116)
This commit is contained in:
Родитель
7d28bb1785
Коммит
406098188c
|
@ -18,7 +18,7 @@ CREATE TEMP FUNCTION udf_contains_tier1_country(x ANY TYPE) AS ( --
|
|||
WITH fxa_events AS (
|
||||
SELECT
|
||||
submission_timestamp,
|
||||
metrics.string.account_user_id_sha256 AS user_id,
|
||||
metrics.string.account_user_id_sha256 AS user_id_sha256,
|
||||
IF(
|
||||
metrics.string.relying_party_oauth_client_id = '',
|
||||
metrics.string.relying_party_service,
|
||||
|
@ -29,7 +29,6 @@ WITH fxa_events AS (
|
|||
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
|
||||
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_medium AS utm_medium,
|
||||
metrics.string.utm_source AS utm_source,
|
||||
|
@ -52,10 +51,9 @@ WITH fxa_events AS (
|
|||
windowed AS (
|
||||
SELECT
|
||||
submission_timestamp,
|
||||
user_id,
|
||||
user_id_sha256,
|
||||
service,
|
||||
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,
|
||||
LOGICAL_OR(event_name = 'reg_complete') OVER w1 AS registered,
|
||||
ARRAY_AGG(event_name) OVER w1 AS service_events,
|
||||
|
@ -63,12 +61,12 @@ windowed AS (
|
|||
fxa_events
|
||||
WHERE
|
||||
DATE(submission_timestamp) = @submission_date
|
||||
AND user_id != ''
|
||||
AND user_id_sha256 != ''
|
||||
AND service != ''
|
||||
QUALIFY
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY
|
||||
user_id,
|
||||
user_id_sha256,
|
||||
service,
|
||||
DATE(submission_timestamp)
|
||||
ORDER BY
|
||||
|
@ -77,7 +75,7 @@ windowed AS (
|
|||
WINDOW
|
||||
w1 AS (
|
||||
PARTITION BY
|
||||
user_id,
|
||||
user_id_sha256,
|
||||
service,
|
||||
DATE(submission_timestamp)
|
||||
ORDER BY
|
||||
|
@ -89,10 +87,9 @@ windowed AS (
|
|||
)
|
||||
SELECT
|
||||
DATE(@submission_date) AS submission_date,
|
||||
windowed.user_id,
|
||||
windowed.user_id_sha256,
|
||||
oa.name AS service,
|
||||
windowed.country,
|
||||
windowed.language,
|
||||
windowed.seen_in_tier1_country,
|
||||
windowed.registered,
|
||||
windowed.service_events,
|
||||
|
@ -102,5 +99,5 @@ JOIN
|
|||
`accounts_db.fxa_oauth_clients` AS oa
|
||||
ON windowed.service = oa.id
|
||||
WHERE
|
||||
user_id IS NOT NULL
|
||||
user_id_sha256 IS NOT NULL
|
||||
AND service IS NOT NULL
|
||||
|
|
|
@ -2,7 +2,7 @@ fields:
|
|||
- name: submission_date
|
||||
type: DATE
|
||||
mode: NULLABLE
|
||||
- name: user_id
|
||||
- name: user_id_sha256
|
||||
type: STRING
|
||||
mode: NULLABLE
|
||||
- name: service
|
||||
|
@ -11,9 +11,6 @@ fields:
|
|||
- name: country
|
||||
type: STRING
|
||||
mode: NULLABLE
|
||||
- name: language
|
||||
type: STRING
|
||||
mode: NULLABLE
|
||||
- name: seen_in_tier1_country
|
||||
type: BOOLEAN
|
||||
mode: NULLABLE
|
||||
|
|
Загрузка…
Ссылка в новой задаче