|
1 | 1 | -- {{ header }} |
2 | | -SELECT |
| 2 | +WITH _previous AS ( |
| 3 | + SELECT |
| 4 | + submission_timestamp, |
| 5 | + client_info.client_id, |
| 6 | + app_version_major |
| 7 | + app_version_minor, |
| 8 | + app_version_patch, |
| 9 | + normalized_channel, |
| 10 | + normalized_country_code, |
| 11 | + normalized_os, |
| 12 | + normalized_os_version, |
| 13 | + is_bot_generated, |
| 14 | + isp_name, |
| 15 | + terms_of_use_version_accepted, |
| 16 | + terms_of_use_date_accepted, |
| 17 | + {% if app_name == "firefox_desktop" %} |
| 18 | + metrics.metrics.uuid.legacy_telemetry_client_id, -- firefox_desktop exclusive field. |
| 19 | + {% endif %} |
| 20 | +FROM |
| 21 | + `{{ project_id }}.{{ app_name }}_derived.{{ table_name }}` |
| 22 | +WHERE |
| 23 | + DATE(submission_timestamp) <= @submission_date |
| 24 | +), |
| 25 | +_current AS ( |
| 26 | + SELECT |
3 | 27 | submission_timestamp, |
4 | 28 | client_info.client_id, |
5 | | - app_version_major, -- noticed a few entries with version 9000, should those be excluded? |
| 29 | + app_version_major, |
6 | 30 | app_version_minor, |
7 | 31 | app_version_patch, |
8 | 32 | normalized_channel, |
|
11 | 35 | normalized_os_version, |
12 | 36 | is_bot_generated, |
13 | 37 | metadata.isp.name AS isp_name, |
14 | | - -- update entry if either of these change: |
15 | 38 | {% if app_name == "firefox_ios" %} |
16 | 39 | metrics.metrics.quantity.user_terms_of_use_version_accepted AS terms_of_use_version_accepted, |
17 | 40 | metrics.metrics.datetime.user_terms_of_use_date_accepted AS terms_of_use_date_accepted, |
|
29 | 52 | DATE(submission_timestamp) >= {% if app_name == "firefox_desktop" %}"2025-06-24"{% else %}"2025-09-15"{% endif %} |
30 | 53 | AND app_version_major >= 142 |
31 | 54 | AND metrics.metrics.datetime.user_terms_of_use_date_accepted IS NOT NULL |
| 55 | +) |
| 56 | + |
| 57 | +SELECT |
| 58 | + -- update entry if `terms_of_use_version_accepted` or `terms_of_use_date_accepted` value changes: |
| 59 | + IF( |
| 60 | + (_current.terms_of_use_version_accepted <> _previous.terms_of_use_version_accepted) |
| 61 | + OR (_current.terms_of_use_date_accepted <> _previous.terms_of_use_date_accepted), |
| 62 | + _current, |
| 63 | + _previous |
| 64 | + ).* |
| 65 | +FROM |
| 66 | + _previous |
| 67 | +FULL OUTER JOIN _current |
| 68 | + USING (client_id, normalized_channel) |
| 69 | + |
0 commit comments