Skip to content

Commit 3b77cfa

Browse files
authored
add process to sample counts glam tables (#2749)
add process to sample counts glam tables
1 parent 5095707 commit 3b77cfa

File tree

3 files changed

+73
-36
lines changed

3 files changed

+73
-36
lines changed

bigquery_etl/glam/templates/extract_sample_counts_v1.sql

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,14 @@ AND total_sample IS NOT NULL
2020
WHERE
2121
cp.app_version IS NOT NULL
2222
AND total_users > {{ total_users }}
23-
AND cp.client_agg_type not in ('sum','min','avg','max')
23+
AND cp.client_agg_type not in ('sum','min','avg','max')
24+
GROUP BY
25+
cp.channel,
26+
cp.ping_type,
27+
cp.app_version,
28+
cp.app_build_id,
29+
cp.os,
30+
cp.metric,
31+
cp.key,
32+
client_agg_type,
33+
total_sample

sql/glam-fenix-dev/glam_etl/org_mozilla_fenix_glam_nightly__extract_sample_counts_v1/query.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,13 @@ WHERE
2323
cp.app_version IS NOT NULL
2424
AND total_users > 10
2525
AND cp.client_agg_type NOT IN ('sum', 'min', 'avg', 'max')
26+
GROUP BY
27+
cp.channel,
28+
cp.ping_type,
29+
cp.app_version,
30+
cp.app_build_id,
31+
cp.os,
32+
cp.metric,
33+
cp.key,
34+
client_agg_type,
35+
total_sample

sql/moz-fx-data-shared-prod/telemetry_derived/glam_sample_counts_v1/query.sql

Lines changed: 52 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ WITH histogram_data AS (
55
app_build_id,
66
channel,
77
metric,
8+
process,
89
key,
910
h1.aggregates
1011
FROM
@@ -31,6 +32,7 @@ SELECT
3132
app_build_id,
3233
channel,
3334
metric,
35+
process,
3436
histogram_data.key,
3537
SUM(v1.value) AS total_sample
3638
FROM
@@ -42,14 +44,16 @@ GROUP BY
4244
app_build_id,
4345
channel,
4446
metric,
47+
process,
4548
key
4649
UNION ALL
4750
SELECT
48-
CAST(NULL AS STRING) AS os,
51+
'*' AS os,
4952
app_version,
5053
app_build_id,
5154
channel,
5255
metric,
56+
process,
5357
histogram_data.key,
5458
SUM(v1.value) AS total_sample
5559
FROM
@@ -60,14 +64,16 @@ GROUP BY
6064
app_build_id,
6165
channel,
6266
metric,
67+
process,
6368
key
6469
UNION ALL
6570
SELECT
6671
os,
6772
app_version,
68-
CAST(NULL AS STRING) AS app_build_id,
73+
'*' AS app_build_id,
6974
channel,
7075
metric,
76+
process,
7177
histogram_data.key,
7278
SUM(v1.value) AS total_sample
7379
FROM
@@ -78,14 +84,16 @@ GROUP BY
7884
app_version,
7985
channel,
8086
metric,
87+
process,
8188
key
8289
UNION ALL
8390
SELECT
84-
CAST(NULL AS STRING) AS os,
91+
'*' AS os,
8592
app_version,
86-
CAST(NULL AS STRING) AS app_build_id,
93+
'*' AS app_build_id,
8794
channel,
8895
metric,
96+
process,
8997
histogram_data.key,
9098
SUM(v1.value) AS total_sample
9199
FROM
@@ -95,18 +103,20 @@ GROUP BY
95103
app_version,
96104
channel,
97105
metric,
106+
process,
98107
key
99108
UNION ALL
100109
SELECT
101110
os,
102111
app_version,
103112
app_build_id,
104113
channel,
105-
s1.metric,
106-
s1.key,
114+
metric,
115+
process,
116+
key,
107117
CASE
108118
WHEN
109-
s1.agg_type IN ('count', 'true', 'false')
119+
agg_type IN ('count', 'true', 'false')
110120
THEN
111121
SUM(value)
112122
ELSE
@@ -115,26 +125,28 @@ SELECT
115125
AS total_sample
116126
FROM
117127
scalars_data,
118-
UNNEST(scalar_aggregates) s1
128+
UNNEST(scalar_aggregates)
119129
GROUP BY
120130
os,
121131
app_version,
122132
app_build_id,
123133
channel,
124-
s1.metric,
125-
s1.key,
126-
s1.agg_type
134+
metric,
135+
process,
136+
key,
137+
agg_type
127138
UNION ALL
128139
SELECT
129-
CAST(NULL AS STRING) AS os,
140+
'*' AS os,
130141
app_version,
131142
app_build_id,
132143
channel,
133-
s1.metric,
134-
s1.key,
144+
metric,
145+
process,
146+
key,
135147
CASE
136148
WHEN
137-
s1.agg_type IN ('count', 'true', 'false')
149+
agg_type IN ('count', 'true', 'false')
138150
THEN
139151
SUM(value)
140152
ELSE
@@ -148,20 +160,22 @@ GROUP BY
148160
app_version,
149161
app_build_id,
150162
channel,
151-
s1.metric,
152-
s1.key,
153-
s1.agg_type
163+
metric,
164+
process,
165+
key,
166+
agg_type
154167
UNION ALL
155168
SELECT
156169
os,
157170
app_version,
158-
CAST(NULL AS STRING) AS app_build_id,
171+
'*' AS app_build_id,
159172
channel,
160-
s1.metric,
161-
s1.key,
173+
metric,
174+
process,
175+
key,
162176
CASE
163177
WHEN
164-
s1.agg_type IN ('count', 'true', 'false')
178+
agg_type IN ('count', 'true', 'false')
165179
THEN
166180
SUM(value)
167181
ELSE
@@ -170,25 +184,27 @@ SELECT
170184
AS total_sample
171185
FROM
172186
scalars_data,
173-
UNNEST(scalar_aggregates) s1
187+
UNNEST(scalar_aggregates)
174188
GROUP BY
175189
os,
176190
app_version,
177191
channel,
178-
s1.metric,
179-
s1.key,
180-
s1.agg_type
192+
metric,
193+
process,
194+
key,
195+
agg_type
181196
UNION ALL
182197
SELECT
183-
CAST(NULL AS STRING) AS os,
198+
'*' AS os,
184199
app_version,
185-
CAST(NULL AS STRING) AS app_build_id,
200+
'*' AS app_build_id,
186201
channel,
187-
s1.metric,
188-
s1.key,
202+
metric,
203+
process,
204+
key,
189205
CASE
190206
WHEN
191-
s1.agg_type IN ('count', 'true', 'false')
207+
agg_type IN ('count', 'true', 'false')
192208
THEN
193209
SUM(value)
194210
ELSE
@@ -197,10 +213,11 @@ SELECT
197213
AS total_sample
198214
FROM
199215
scalars_data,
200-
UNNEST(scalar_aggregates) s1
216+
UNNEST(scalar_aggregates)
201217
GROUP BY
202218
app_version,
203219
channel,
204-
s1.metric,
205-
s1.key,
206-
s1.agg_type
220+
metric,
221+
process,
222+
key,
223+
agg_type

0 commit comments

Comments
 (0)