feat: remove fields we do not need for kpi reporting

This commit is contained in:
kik-kik 2024-10-17 14:44:29 +02:00
Родитель b22f43685d
Коммит a1956dce7a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 77A4696F55505449
2 изменённых файлов: 31 добавлений и 28 удалений

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

@ -1,32 +1,19 @@
{{ header }} {{ header }}
SELECT SELECT
submission_date, submission_date,
-- client_id,
app_name, app_name,
normalized_channel, normalized_channel,
EXTRACT(YEAR FROM first_seen_date) AS first_seen_year, first_seen_year,
submission_date = first_seen_date AS is_new_profile, is_new_profile,
IFNULL(country, '??') country, country,
city, locale,
COALESCE(REGEXP_EXTRACT(locale, r'^(.+?)-'), locale, NULL) AS locale, -- normalized_os,
normalized_os, os_version_major,
-- normalized_os_version, os_version_minor,
COALESCE( os_version_patch,
SAFE_CAST(NULLIF(SPLIT(normalized_os_version, ".")[SAFE_OFFSET(0)], "") AS INTEGER), app_version,
0
) AS os_version_major,
COALESCE(
SAFE_CAST(NULLIF(SPLIT(normalized_os_version, ".")[SAFE_OFFSET(1)], "") AS INTEGER),
0
) AS os_version_minor,
COALESCE(
SAFE_CAST(NULLIF(SPLIT(normalized_os_version, ".")[SAFE_OFFSET(2)], "") AS INTEGER),
0
) AS os_version_patch,
app_display_version AS app_version,
device_model,
distribution_id, distribution_id,
activity_segment AS segment, segment,
COUNTIF(is_daily_user) AS daily_users, COUNTIF(is_daily_user) AS daily_users,
COUNTIF(is_weekly_user) AS weekly_users, COUNTIF(is_weekly_user) AS weekly_users,
COUNTIF(is_monthly_user) AS monthly_users, COUNTIF(is_monthly_user) AS monthly_users,
@ -46,13 +33,10 @@ GROUP BY
first_seen_year, first_seen_year,
is_new_profile, is_new_profile,
country, country,
city,
locale, locale,
normalized_os,
os_version_major, os_version_major,
os_version_minor, os_version_minor,
os_version_patch, os_version_patch,
app_version, app_version,
device_model,
distribution_id, distribution_id,
segment segment

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

@ -3,7 +3,11 @@ CREATE OR REPLACE VIEW
`{{ project_id }}.{{ dataset }}.{{ name }}` `{{ project_id }}.{{ dataset }}.{{ name }}`
AS AS
SELECT SELECT
* EXCEPT (isp), * EXCEPT (isp, normalized_os_version, app_display_version)
REPLACE(
COALESCE(REGEXP_EXTRACT(locale, r'^(.+?)-'), locale, NULL) AS locale,
IFNULL(country, '??') AS country
),
CASE CASE
WHEN LOWER(isp) = "browserstack" WHEN LOWER(isp) = "browserstack"
THEN CONCAT("{{ friendly_name }}", " ", isp) THEN CONCAT("{{ friendly_name }}", " ", isp)
@ -28,7 +32,22 @@ SELECT
WHEN BIT_COUNT(days_active_bits) >= 21 WHEN BIT_COUNT(days_active_bits) >= 21
THEN "core_user" THEN "core_user"
ELSE "other" ELSE "other"
END AS activity_segment, END AS segment,
COALESCE(
SAFE_CAST(NULLIF(SPLIT(normalized_os_version, ".")[SAFE_OFFSET(0)], "") AS INTEGER),
0
) AS os_version_major,
COALESCE(
SAFE_CAST(NULLIF(SPLIT(normalized_os_version, ".")[SAFE_OFFSET(1)], "") AS INTEGER),
0
) AS os_version_minor,
COALESCE(
SAFE_CAST(NULLIF(SPLIT(normalized_os_version, ".")[SAFE_OFFSET(2)], "") AS INTEGER),
0
) AS os_version_patch,
app_display_version AS app_version,
EXTRACT(YEAR FROM first_seen_date) AS first_seen_year,
submission_date = first_seen_date AS is_new_profile,
IFNULL(mozfun.bits28.days_since_seen(days_active_bits) = 0, FALSE) AS is_dau, IFNULL(mozfun.bits28.days_since_seen(days_active_bits) = 0, FALSE) AS is_dau,
IFNULL(mozfun.bits28.days_since_seen(days_active_bits) < 7, FALSE) AS is_wau, IFNULL(mozfun.bits28.days_since_seen(days_active_bits) < 7, FALSE) AS is_wau,
IFNULL(mozfun.bits28.days_since_seen(days_active_bits) < 28, FALSE) AS is_mau, IFNULL(mozfun.bits28.days_since_seen(days_active_bits) < 28, FALSE) AS is_mau,