Skip to content

Commit 991f37d

Browse files
authored
feat(DENG-9984): Create Glean version of fx_health_ind_np_by_install_type (#8389)
* feat(DENG-9984): Create Glean version of fx_health_ind_np_by_install_type * Update metadata.yaml * Fix query condition for submission date comparison
1 parent 97b0405 commit 991f37d

File tree

5 files changed

+132
-0
lines changed

5 files changed

+132
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
friendly_name: Firefox Health Indicator - New Profiles by Installer Type
2+
description: |-
3+
Calculates new profiles per installer type for Windows clients; used in Firefox Health Indicator dashboard
4+
Only looks at a 1% sample of all clients (i.e. sample ID = 0)
5+
owners:
6+
7+
labels:
8+
owner: kwindau
9+
require_column_descriptions: false
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CREATE OR REPLACE VIEW
2+
`moz-fx-data-shared-prod.firefox_desktop.fx_health_ind_np_by_install_type`
3+
AS
4+
SELECT
5+
*
6+
FROM
7+
`moz-fx-data-shared-prod.firefox_desktop_derived.fx_health_ind_np_by_install_type_v1`
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
friendly_name: Firefox Health Indicator - New Profiles by Installer Type
2+
description: |-
3+
Calculates new profiles per installer type for Windows clients; used in Firefox Health Indicator dashboard
4+
Only looks at a 1% sample of all clients (i.e. sample ID = 0)
5+
owners:
6+
7+
labels:
8+
incremental: true
9+
owner1: kwindau
10+
table_type: aggregate
11+
scheduling:
12+
dag_name: bqetl_fx_health_ind_dashboard
13+
depends_on_past: false
14+
date_partition_offset: -7
15+
date_partition_parameter: fsd
16+
parameters:
17+
- submission_date:DATE:{{ds}}
18+
bigquery:
19+
time_partitioning:
20+
type: day
21+
field: first_seen_date
22+
require_partition_filter: false
23+
expiration_days: null
24+
range_partitioning: null
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
WITH first_install_type AS (
2+
SELECT
3+
client_id,
4+
REGEXP_REPLACE(`event`, 'installation.first_seen_', "") AS installer_type,
5+
ROW_NUMBER() OVER (PARTITION BY client_id ORDER BY submission_timestamp ASC) AS rnk
6+
FROM
7+
`moz-fx-data-shared-prod.firefox_desktop.events_stream`
8+
WHERE
9+
event_category = 'installation'
10+
AND sample_id = 0
11+
AND DATE(submission_timestamp) < @submission_date
12+
QUALIFY
13+
rnk = 1
14+
),
15+
staging AS (
16+
SELECT
17+
client_id,
18+
first_seen_date,
19+
submission_date,
20+
days_interacted_bits & days_visited_1_uri_bits AS active_days_bits
21+
FROM
22+
`moz-fx-data-shared-prod.firefox_desktop.baseline_clients_last_seen`
23+
WHERE
24+
first_seen_date = @fsd
25+
AND submission_date
26+
BETWEEN @fsd
27+
AND DATE_SUB(@submission_date, INTERVAL 1 DAY)
28+
AND sample_id = 0
29+
),
30+
cls AS (
31+
SELECT
32+
stg.client_id,
33+
stg.first_seen_date,
34+
fit.installer_type,
35+
stg.submission_date,
36+
stg.active_days_bits
37+
FROM
38+
staging stg
39+
JOIN
40+
first_install_type fit
41+
ON stg.client_id = fit.client_id
42+
),
43+
final_stg AS (
44+
SELECT
45+
first_seen_date,
46+
installer_type,
47+
COUNT(1) AS nbr_rows,
48+
COUNT(DISTINCT(CLIENT_ID)) AS new_profiles,
49+
SUM(BIT_COUNT(active_days_bits)) AS sum_active_days_bit_count_for_new_profiles
50+
FROM
51+
cls
52+
GROUP BY
53+
first_seen_date,
54+
installer_type
55+
)
56+
SELECT
57+
first_seen_date,
58+
installer_type,
59+
nbr_rows,
60+
new_profiles,
61+
sum_active_days_bit_count_for_new_profiles,
62+
SAFE_DIVIDE(
63+
sum_active_days_bit_count_for_new_profiles,
64+
new_profiles
65+
) AS ratio_of_np_days_active_bits_vs_np_first_7_days
66+
FROM
67+
final_stg
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
fields:
2+
- mode: NULLABLE
3+
name: first_seen_date
4+
type: DATE
5+
description: First Seen Date
6+
- mode: NULLABLE
7+
name: installer_type
8+
type: STRING
9+
description: Installer Type - The first install type associated with the client ID; for example, msix, full, or stub
10+
- mode: NULLABLE
11+
name: nbr_rows
12+
type: INTEGER
13+
description: Count of Rows in Clients Last Seen for These New Profiles for First 7 Days
14+
- mode: NULLABLE
15+
name: new_profiles
16+
type: INTEGER
17+
description: Number of new profiles first seen on this date with this installer type
18+
- mode: NULLABLE
19+
name: sum_active_days_bit_count_for_new_profiles
20+
type: INTEGER
21+
description: The sum of the "days active bits" in the next 7 days for these new profiles
22+
- mode: NULLABLE
23+
name: ratio_of_np_days_active_bits_vs_np_first_7_days
24+
type: FLOAT
25+
description: Calculated as sum_active_days_bit_count_for_new_profiles divided by new_profiles

0 commit comments

Comments
 (0)