Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1735563 - Add events_daily for Mozilla VPN (#2429)
Co-authored-by: akkomar <akkomar@users.noreply.github.com>
- Loading branch information
Showing
20 changed files
with
739 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- Generated by bigquery_etl/events_daily/generate_queries.py | ||
CREATE OR REPLACE VIEW | ||
`moz-fx-data-shared-prod.mozilla_vpn.event_types` | ||
AS | ||
SELECT | ||
* | ||
FROM | ||
`moz-fx-data-shared-prod.mozilla_vpn_derived.event_types_v1` |
8 changes: 8 additions & 0 deletions
8
sql/moz-fx-data-shared-prod/mozilla_vpn/events_daily/view.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- Generated by bigquery_etl/events_daily/generate_queries.py | ||
CREATE OR REPLACE VIEW | ||
`moz-fx-data-shared-prod.mozilla_vpn.events_daily` | ||
AS | ||
SELECT | ||
* | ||
FROM | ||
`moz-fx-data-shared-prod.mozilla_vpn_derived.events_daily_v1` |
162 changes: 162 additions & 0 deletions
162
sql/moz-fx-data-shared-prod/mozilla_vpn_derived/event_types_history_v1/init.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
-- Generated by bigquery_etl/events_daily/generate_queries.py | ||
CREATE OR REPLACE TABLE | ||
mozilla_vpn_derived.event_types_history_v1 | ||
PARTITION BY | ||
submission_date | ||
CLUSTER BY | ||
category, | ||
event | ||
AS | ||
WITH source AS ( | ||
SELECT | ||
DATE(submission_timestamp) AS submission_date, | ||
SAFE.TIMESTAMP_ADD(ping_info.parsed_start_time, INTERVAL timestamp MILLISECOND) AS timestamp, | ||
category, | ||
name AS event, | ||
extra, | ||
FROM | ||
mozillavpn.main e | ||
CROSS JOIN | ||
UNNEST(e.events) AS event | ||
), | ||
sample AS ( | ||
SELECT | ||
* | ||
FROM | ||
source | ||
WHERE | ||
submission_date >= '2021-10-01' | ||
), | ||
primary_event_types AS ( | ||
SELECT | ||
category, | ||
event, | ||
MIN(timestamp) AS first_timestamp, | ||
ROW_NUMBER() OVER (ORDER BY MIN(timestamp) ASC, category ASC, event ASC) AS primary_index, | ||
FROM | ||
sample | ||
GROUP BY | ||
category, | ||
event | ||
), | ||
event_property_indices AS ( | ||
SELECT | ||
category, | ||
event, | ||
MIN(timestamp) AS first_timestamp, | ||
event_property.key AS event_property, | ||
ROW_NUMBER() OVER ( | ||
PARTITION BY | ||
category, | ||
event | ||
ORDER BY | ||
MIN(timestamp) ASC, | ||
event_property.key ASC | ||
) AS event_property_index, | ||
FROM | ||
sample, | ||
UNNEST(extra) AS event_property | ||
LEFT JOIN | ||
UNNEST(CAST(['time_ms'] AS ARRAY<STRING>)) skipped_property | ||
ON | ||
skipped_property = event_property.key | ||
WHERE | ||
skipped_property IS NULL | ||
GROUP BY | ||
category, | ||
event, | ||
event_property | ||
), | ||
event_property_value_indices AS ( | ||
SELECT | ||
category, | ||
event, | ||
MIN(timestamp) AS first_timestamp, | ||
event_property.key AS event_property, | ||
event_property.value AS event_property_value, | ||
ROW_NUMBER() OVER ( | ||
PARTITION BY | ||
category, | ||
event, | ||
event_property.key | ||
ORDER BY | ||
MIN(timestamp) ASC, | ||
event_property.value ASC | ||
) AS event_property_value_index, | ||
FROM | ||
sample, | ||
UNNEST(extra) AS event_property | ||
GROUP BY | ||
category, | ||
event, | ||
event_property, | ||
event_property_value | ||
), | ||
per_event_property AS ( | ||
SELECT | ||
category, | ||
event, | ||
event_property, | ||
event_property_index, | ||
ARRAY_AGG( | ||
STRUCT( | ||
event_property_value AS key, | ||
udf.event_code_points_to_string([event_property_value_index]) AS value, | ||
event_property_value_index AS index | ||
) | ||
ORDER BY | ||
event_property_value_index ASC | ||
) AS values, | ||
FROM | ||
event_property_value_indices | ||
INNER JOIN | ||
event_property_indices | ||
USING | ||
(category, event, event_property) | ||
WHERE | ||
event_property_value_index <= 1000 | ||
GROUP BY | ||
category, | ||
event, | ||
event_property, | ||
event_property_index | ||
), | ||
per_event AS ( | ||
SELECT | ||
category, | ||
event, | ||
first_timestamp, | ||
primary_index AS numeric_index, | ||
udf.event_code_points_to_string([primary_index]) AS index, | ||
ARRAY_AGG( | ||
IF( | ||
event_property IS NULL, | ||
NULL, | ||
STRUCT(event_property AS key, VALUES AS value, event_property_index AS index) | ||
) IGNORE NULLS | ||
ORDER BY | ||
event_property_index ASC | ||
) AS event_properties | ||
FROM | ||
primary_event_types | ||
LEFT JOIN | ||
per_event_property | ||
USING | ||
(category, event) | ||
GROUP BY | ||
category, | ||
event, | ||
first_timestamp, | ||
primary_index | ||
), | ||
max_date AS ( | ||
SELECT | ||
MAX(submission_date) AS submission_date | ||
FROM | ||
sample | ||
) | ||
SELECT | ||
* | ||
FROM | ||
per_event, | ||
max_date |
19 changes: 19 additions & 0 deletions
19
sql/moz-fx-data-shared-prod/mozilla_vpn_derived/event_types_history_v1/metadata.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by bigquery_etl/events_daily/generate_queries.py | ||
|
||
--- | ||
friendly_name: 'Mozilla VPN Event Types History' | ||
description: > | ||
Retrieve the set of [events, event_properties] | ||
and record them in a table. | ||
This table stores all of history, partitioned by | ||
submission_date. | ||
owners: | ||
- wlachance@mozilla.com | ||
- akomar@mozilla.com | ||
labels: | ||
application: mozilla_vpn | ||
incremental: true | ||
schedule: daily | ||
scheduling: | ||
dag_name: bqetl_event_rollup | ||
depends_on_past: true |
Oops, something went wrong.