-
Notifications
You must be signed in to change notification settings - Fork 113
Use fixed column order in baseline_clients_last_seen #7119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
BenWu
wants to merge
1
commit into
main
Choose a base branch
from
benwu/bcls-struct-order
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -44,7 +44,38 @@ WITH _current AS ( | |||||||||||||||||||||||||||||||||||||||||
CAST(browser_engagement_uri_count > 0 AS INT64) & | ||||||||||||||||||||||||||||||||||||||||||
CAST(browser_engagement_active_ticks > 0 AS INT64) AS days_desktop_active_bits, | ||||||||||||||||||||||||||||||||||||||||||
{% endif %} | ||||||||||||||||||||||||||||||||||||||||||
* EXCEPT(submission_date) | ||||||||||||||||||||||||||||||||||||||||||
client_id, | ||||||||||||||||||||||||||||||||||||||||||
sample_id, | ||||||||||||||||||||||||||||||||||||||||||
first_run_date, | ||||||||||||||||||||||||||||||||||||||||||
durations, | ||||||||||||||||||||||||||||||||||||||||||
days_seen_session_start_bits, | ||||||||||||||||||||||||||||||||||||||||||
days_seen_session_end_bits, | ||||||||||||||||||||||||||||||||||||||||||
normalized_channel, | ||||||||||||||||||||||||||||||||||||||||||
normalized_os, | ||||||||||||||||||||||||||||||||||||||||||
normalized_os_version, | ||||||||||||||||||||||||||||||||||||||||||
android_sdk_version, | ||||||||||||||||||||||||||||||||||||||||||
locale, | ||||||||||||||||||||||||||||||||||||||||||
city, | ||||||||||||||||||||||||||||||||||||||||||
country, | ||||||||||||||||||||||||||||||||||||||||||
isp, | ||||||||||||||||||||||||||||||||||||||||||
app_build, | ||||||||||||||||||||||||||||||||||||||||||
app_channel, | ||||||||||||||||||||||||||||||||||||||||||
app_display_version, | ||||||||||||||||||||||||||||||||||||||||||
architecture, | ||||||||||||||||||||||||||||||||||||||||||
device_manufacturer, | ||||||||||||||||||||||||||||||||||||||||||
device_model, | ||||||||||||||||||||||||||||||||||||||||||
telemetry_sdk_build, | ||||||||||||||||||||||||||||||||||||||||||
first_seen_date, | ||||||||||||||||||||||||||||||||||||||||||
is_new_profile, | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+60
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'd be good if this query's column order matched the
Suggested change
Or alternatively, the |
||||||||||||||||||||||||||||||||||||||||||
distribution_id, | ||||||||||||||||||||||||||||||||||||||||||
geo_subdivision, | ||||||||||||||||||||||||||||||||||||||||||
profile_group_id, | ||||||||||||||||||||||||||||||||||||||||||
install_source, | ||||||||||||||||||||||||||||||||||||||||||
windows_build_number, | ||||||||||||||||||||||||||||||||||||||||||
browser_engagement_uri_count, | ||||||||||||||||||||||||||||||||||||||||||
browser_engagement_active_ticks, | ||||||||||||||||||||||||||||||||||||||||||
legacy_telemetry_client_id, | ||||||||||||||||||||||||||||||||||||||||||
is_default_browser, | ||||||||||||||||||||||||||||||||||||||||||
FROM | ||||||||||||||||||||||||||||||||||||||||||
`{{ daily_table }}` | ||||||||||||||||||||||||||||||||||||||||||
WHERE | ||||||||||||||||||||||||||||||||||||||||||
|
@@ -54,21 +85,46 @@ WITH _current AS ( | |||||||||||||||||||||||||||||||||||||||||
-- | ||||||||||||||||||||||||||||||||||||||||||
_previous AS ( | ||||||||||||||||||||||||||||||||||||||||||
SELECT | ||||||||||||||||||||||||||||||||||||||||||
-- All columns except submission_date ( * (EXCEPT(submission_date)) ) | ||||||||||||||||||||||||||||||||||||||||||
-- listed out to ensure order is identical to output of _current | ||||||||||||||||||||||||||||||||||||||||||
days_seen_bits, | ||||||||||||||||||||||||||||||||||||||||||
days_active_bits, | ||||||||||||||||||||||||||||||||||||||||||
{% if app_name == "firefox_desktop" %} | ||||||||||||||||||||||||||||||||||||||||||
days_desktop_active_bits, | ||||||||||||||||||||||||||||||||||||||||||
{% endif %} | ||||||||||||||||||||||||||||||||||||||||||
days_created_profile_bits, | ||||||||||||||||||||||||||||||||||||||||||
* EXCEPT ( | ||||||||||||||||||||||||||||||||||||||||||
submission_date, | ||||||||||||||||||||||||||||||||||||||||||
days_seen_bits, | ||||||||||||||||||||||||||||||||||||||||||
days_active_bits, | ||||||||||||||||||||||||||||||||||||||||||
{% if app_name == "firefox_desktop" %} | ||||||||||||||||||||||||||||||||||||||||||
days_desktop_active_bits, | ||||||||||||||||||||||||||||||||||||||||||
{% endif %} | ||||||||||||||||||||||||||||||||||||||||||
days_created_profile_bits | ||||||||||||||||||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||||||||||||||||||
client_id, | ||||||||||||||||||||||||||||||||||||||||||
sample_id, | ||||||||||||||||||||||||||||||||||||||||||
first_run_date, | ||||||||||||||||||||||||||||||||||||||||||
durations, | ||||||||||||||||||||||||||||||||||||||||||
days_seen_session_start_bits, | ||||||||||||||||||||||||||||||||||||||||||
days_seen_session_end_bits, | ||||||||||||||||||||||||||||||||||||||||||
normalized_channel, | ||||||||||||||||||||||||||||||||||||||||||
normalized_os, | ||||||||||||||||||||||||||||||||||||||||||
normalized_os_version, | ||||||||||||||||||||||||||||||||||||||||||
android_sdk_version, | ||||||||||||||||||||||||||||||||||||||||||
locale, | ||||||||||||||||||||||||||||||||||||||||||
city, | ||||||||||||||||||||||||||||||||||||||||||
country, | ||||||||||||||||||||||||||||||||||||||||||
isp, | ||||||||||||||||||||||||||||||||||||||||||
app_build, | ||||||||||||||||||||||||||||||||||||||||||
app_channel, | ||||||||||||||||||||||||||||||||||||||||||
app_display_version, | ||||||||||||||||||||||||||||||||||||||||||
architecture, | ||||||||||||||||||||||||||||||||||||||||||
device_manufacturer, | ||||||||||||||||||||||||||||||||||||||||||
device_model, | ||||||||||||||||||||||||||||||||||||||||||
telemetry_sdk_build, | ||||||||||||||||||||||||||||||||||||||||||
first_seen_date, | ||||||||||||||||||||||||||||||||||||||||||
is_new_profile, | ||||||||||||||||||||||||||||||||||||||||||
distribution_id, | ||||||||||||||||||||||||||||||||||||||||||
geo_subdivision, | ||||||||||||||||||||||||||||||||||||||||||
profile_group_id, | ||||||||||||||||||||||||||||||||||||||||||
install_source, | ||||||||||||||||||||||||||||||||||||||||||
windows_build_number, | ||||||||||||||||||||||||||||||||||||||||||
browser_engagement_uri_count, | ||||||||||||||||||||||||||||||||||||||||||
browser_engagement_active_ticks, | ||||||||||||||||||||||||||||||||||||||||||
legacy_telemetry_client_id, | ||||||||||||||||||||||||||||||||||||||||||
is_default_browser, | ||||||||||||||||||||||||||||||||||||||||||
FROM | ||||||||||||||||||||||||||||||||||||||||||
`{{ last_seen_table }}` | ||||||||||||||||||||||||||||||||||||||||||
WHERE | ||||||||||||||||||||||||||||||||||||||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're going to the effort of fixing column orders in this query, there are a couple other cases it'd be good to fix up:
submission_date
after the*_bits
columns. I'd recommend we havesubmission_date
be the first column in the init query like it is in the main query (IMO partition columns should always be the first column in the schema)._previous
CTE has the*_bits
columns in a different order than the init query and the_current
CTE. Luckily because theIF(_current.client_id IS NOT NULL, _current, _previous).* REPLACE (...)
expression is replacing those*_bits
columns with explicit references to the associated columns from_current
and_previous
the end result is correct. However, if those*_bits
columns weren't being replaced like that this would silently be doing the wrong thing (similar to unioning two queries with different column orders), so IMO it would be good to make the*_bits
column order in_previous
match the other two cases.