Skip to content

Commit

Permalink
View SQL Query accounts for normalization (#2878)
Browse files Browse the repository at this point in the history
  • Loading branch information
edugfilho authored Jun 26, 2024
1 parent 44f43bd commit 7edbab6
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/components/SqlModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
: `AND normalized_os="${$store.productDimensions.os}"`;
const buildId = $store.ref || $store.defaultRef;
const normalized = $store.productDimensions.normalizationType === "normalized";
return _.template(sqlTemplate)({
metric: $store.probe.name,
Expand All @@ -111,6 +112,7 @@
telemetryPath,
osFilter,
buildId,
normalized,
});
}
Expand Down
18 changes: 12 additions & 6 deletions src/stringTemplates/desktop-distribution.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,23 @@ WITH per_build_client_day AS (
SELECT
PARSE_DATETIME("%Y%m%d%H%M%S", application.build_id) AS build_id,
client_id,
mozfun.hist.normalize(
<% if(normalized) { %>mozfun.hist.normalize(
mozfun.hist.merge(
ARRAY_AGG(
mozfun.hist.extract(
${ telemetryPath }
) IGNORE NULLS
)
)
) AS ${ metric }
)<% } else { %>mozfun.hist.merge(
ARRAY_AGG(
mozfun.hist.extract(
${ telemetryPath }
) IGNORE NULLS
)
)<% } %> AS ${ metric }
FROM
telemetry.${ table }
moz-fx-data-shared-prod.telemetry.${ table }
WHERE
normalized_channel = '${ channel }'
${ osFilter }
Expand Down Expand Up @@ -69,12 +75,12 @@ as_struct AS (
build_id,
ARRAY_AGG(STRUCT(key_string, value))AS merged_${ metric }
FROM filtered
GROUP by
GROUP by
build_id
)

SELECT build_id,
key_string as key,
SELECT build_id,
key_string as key,
value as bucket
FROM as_struct
CROSS JOIN
Expand Down
14 changes: 10 additions & 4 deletions src/stringTemplates/desktop-histogram-proportions.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,23 @@ WITH per_build_client_day AS (
SELECT
PARSE_DATETIME("%Y%m%d%H%M%S", application.build_id) AS build_id,
client_id,
mozfun.hist.normalize(
<% if(normalized) { %>mozfun.hist.normalize(
mozfun.hist.merge(
ARRAY_AGG(
mozfun.hist.extract(
${ telemetryPath }
) IGNORE NULLS
)
)
) AS ${ metric }
)<% } else { %>mozfun.hist.merge(
ARRAY_AGG(
mozfun.hist.extract(
${ telemetryPath }
) IGNORE NULLS
)
)<% } %> AS ${ metric }
FROM
telemetry.${ table }
moz-fx-data-shared-prod.telemetry.${ table }
WHERE
normalized_channel = '${ channel }'
${ osFilter }
Expand Down Expand Up @@ -84,4 +90,4 @@ FROM
proportions
ORDER BY
build_id desc,
KEY ASC;
KEY ASC;
12 changes: 9 additions & 3 deletions src/stringTemplates/desktop-telemetry.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,23 @@ WITH per_build_client_day AS (
SELECT
PARSE_DATETIME("%Y%m%d%H%M%S", application.build_id) AS build_id,
client_id,
mozfun.hist.normalize(
<% if(normalized) { %>mozfun.hist.normalize(
mozfun.hist.merge(
ARRAY_AGG(
mozfun.hist.extract(
${ telemetryPath }
) IGNORE NULLS
)
)
) AS ${ metric }
)<% } else { %>mozfun.hist.merge(
ARRAY_AGG(
mozfun.hist.extract(
${ telemetryPath }
) IGNORE NULLS
)
)<% } %> AS ${ metric }
FROM
telemetry.${ table }
moz-fx-data-shared-prod.telemetry.${ table }
WHERE
normalized_channel = '${ channel }'
${ osFilter }
Expand Down

0 comments on commit 7edbab6

Please sign in to comment.