Fully qualified identifiers in SQL queries (#5764)

* Add fully-qualified identifiers when formatting queries

* Fully-qualified identifiers for queries in sql/

* Check in only formatted SQL to generated-sql branch

* Add comment

* Fully qualify more tables

* Fully qualify test files

* Formatting improvements around CTEs and unit tests

* Option to skip auto qualifying queries
This commit is contained in:
Anna Scholtz 2024-06-27 09:53:33 -07:00 коммит произвёл GitHub
Родитель b5cab3fc3d
Коммит 57bd939905
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
474 изменённых файлов: 1283 добавлений и 712 удалений

Просмотреть файл

@ -565,6 +565,7 @@ jobs:
PATH="venv/bin:$PATH" script/bqetl metadata update \
--sql-dir /tmp/workspace/generated-sql/sql/ \
/tmp/workspace/generated-sql/sql/
PATH="venv/bin:$PATH" script/bqetl format /tmp/workspace/generated-sql/sql/
- persist_to_workspace:
root: /tmp/workspace
paths:
@ -791,6 +792,7 @@ jobs:
PATH="venv/bin:$PATH" script/bqetl metadata update \
--sql-dir /tmp/workspace/private-generated-sql/sql/ \
/tmp/workspace/private-generated-sql/sql/
PATH="venv/bin:$PATH" script/bqetl format /tmp/workspace/private-generated-sql/sql/
# Change directory to generate DAGs so `sql_file_path` values are relative to the repo root.
export PATH="$PWD/venv/bin:$PATH"
@ -946,6 +948,7 @@ jobs:
--sql-dir /tmp/workspace/main-generated-sql/sql/ \
/tmp/workspace/main-generated-sql/sql/
# re-generate DAGs
./script/bqetl format /tmp/workspace/main-generated-sql/sql/
./script/bqetl dag generate \
--sql-dir /tmp/workspace/main-generated-sql/sql/ \

Просмотреть файл

@ -4,9 +4,11 @@ import glob
import os
import os.path
import sys
from pathlib import Path
from bigquery_etl.config import ConfigLoader
from bigquery_etl.format_sql.formatter import reformat # noqa E402
from bigquery_etl.util.common import qualify_table_references_in_file
def skip_format():
@ -18,6 +20,17 @@ def skip_format():
]
def skip_qualifying_references():
"""Return a list of configured queries where fully qualifying references should be skipped."""
return [
file
for skip in ConfigLoader.get(
"format", "skip_qualifying_references", fallback=[]
)
for file in glob.glob(skip, recursive=True)
]
def format(paths, check=False):
"""Format SQL files."""
if not paths:
@ -40,7 +53,7 @@ def format(paths, check=False):
# skip tests/**/input.sql
and not (path.startswith("tests") and filename == "input.sql")
for filepath in [os.path.join(dirpath, filename)]
if filepath not in skip_format()
if not any([filepath.endswith(s) for s in skip_format()])
)
elif path:
sql_files.append(path)
@ -50,9 +63,19 @@ def format(paths, check=False):
sql_files.sort()
reformatted = unchanged = 0
for path in sql_files:
with open(path) as fp:
query = fp.read()
formatted = reformat(query, trailing_newline=True)
query = Path(path).read_text()
try:
if not any([path.endswith(s) for s in skip_qualifying_references()]):
fully_referenced_query = qualify_table_references_in_file(
Path(path)
)
else:
fully_referenced_query = query
except NotImplementedError:
fully_referenced_query = query # not implemented for scripts
formatted = reformat(fully_referenced_query, trailing_newline=True)
if query != formatted:
if check:
print(f"Needs reformatting: bqetl format {path}")

Просмотреть файл

@ -9,9 +9,10 @@ import string
import tempfile
import warnings
from pathlib import Path
from typing import List
from typing import List, Set, Tuple
from uuid import uuid4
import sqlglot
from google.cloud import bigquery
from jinja2 import Environment, FileSystemLoader
@ -162,6 +163,130 @@ def write_sql(output_dir, full_table_id, basename, sql, skip_existing=False):
f.write("\n")
def qualify_table_references_in_file(path: Path) -> str:
"""Add project id and dataset id to table/view references and persistent udfs in a given query.
e.g.:
`table` -> `target_project.default_dataset.table`
`dataset.table` -> `target_project.dataset.table`
This allows a query to run in a different project than the sql dir it is located in
while referencing the same tables.
"""
# sqlglot cannot handle scripts with variables and control statements
if re.search(
r"^\s*DECLARE\b", path.read_text(), flags=re.MULTILINE
) or path.name in ("script.sql", "udf.sql"):
raise NotImplementedError(
"Cannot qualify table_references of query scripts or UDFs"
)
# determine the default target project and dataset from the path
target_project = Path(path).parent.parent.parent.name
default_dataset = Path(path).parent.parent.name
# sqlglot doesn't support Jinja, so we need to render the queries and
# init queries to raw SQL
sql_query = render(
path.name,
template_folder=path.parent,
format=False,
**DEFAULT_QUERY_TEMPLATE_VARS,
)
init_query = render(
path.name,
template_folder=path.parent,
format=False,
is_init=lambda: True,
metrics=MetricHub(),
)
# use sqlglot to get the SQL AST
init_query_statements = sqlglot.parse(
init_query,
read="bigquery",
)
sql_query_statements = sqlglot.parse(sql_query, read="bigquery")
# tuples of (table identifier, replacement string)
table_replacements: Set[Tuple[str, str]] = set()
# find all non-fully qualified table/view references including backticks
for query in [init_query_statements, sql_query_statements]:
for statement in query:
if statement is None:
continue
cte_names = {
cte.alias_or_name.lower() for cte in statement.find_all(sqlglot.exp.CTE)
}
table_aliases = {
cte.alias_or_name.lower()
for cte in statement.find_all(sqlglot.exp.TableAlias)
}
for table_expr in statement.find_all(sqlglot.exp.Table):
# existing table ref including backticks without alias
table_expr.set("alias", "")
reference_string = table_expr.sql(dialect="bigquery")
matched_cte = [
re.match(
rf"^{cte}(?![a-zA-Z0-9_])",
reference_string.replace("`", "").lower(),
)
for cte in cte_names.union(table_aliases)
]
if any(matched_cte):
continue
# project id is parsed as the catalog attribute
# but information_schema region may also be parsed as catalog
if table_expr.catalog.startswith("region-"):
project_name = f"{target_project}.{table_expr.catalog}"
elif table_expr.catalog == "": # no project id
project_name = target_project
else: # project id exists
continue
# fully qualified table ref
replacement_string = f"`{project_name}.{table_expr.db or default_dataset}.{table_expr.name}`"
table_replacements.add((reference_string, replacement_string))
updated_query = path.read_text()
for identifier, replacement in table_replacements:
if identifier.count(".") == 0:
# if no dataset and project, only replace if it follows a FROM, JOIN, or implicit cross join
regex = (
r"(?P<from>(FROM|JOIN)\s+)"
r"(?P<cross_join>[a-zA-Z0-9_`.\-]+\s*,\s*)?"
rf"{identifier}(?![a-zA-Z0-9_`.])"
)
replacement = r"\g<from>\g<cross_join>" + replacement
else:
identifier = identifier.replace(".", r"\.")
# ensure match is against the full identifier and no project id already
regex = rf"(?<![a-zA-Z0-9_`.]){identifier}(?![a-zA-Z0-9_`.])"
updated_query = re.sub(
re.compile(regex),
replacement,
updated_query,
)
# replace udfs from udf/udf_js that do not have a project qualifier
regex = r"(?<![a-zA-Z0-9_.])`?(?P<dataset>udf(_js)?)`?\.`?(?P<name>[a-zA-Z0-9_]+)`?"
updated_query = re.sub(
re.compile(regex),
rf"`{target_project}.\g<dataset>.\g<name>`",
updated_query,
)
return updated_query
class TempDatasetReference(bigquery.DatasetReference):
"""Extend DatasetReference to simplify generating temporary tables."""

Просмотреть файл

@ -194,12 +194,8 @@ dry_run:
format:
skip:
- bigquery_etl/glam/templates/*.sql
- sql_generators/events_daily/templates/**/*.sql
- sql_generators/glean_usage/templates/*.sql
- sql_generators/search/templates/*.sql
- sql_generators/experiment_monitoring/templates/**/*.sql
- sql_generators/feature_usage/templates/*.sql
- sql_generators/funnels/templates/*.sql
- sql_generators/**/*.sql
- tests/**/*.sql
- sql/moz-fx-data-shared-prod/telemetry/fenix_events_v1/view.sql
- sql/moz-fx-data-shared-prod/telemetry/fennec_ios_events_v1/view.sql
- sql/moz-fx-data-shared-prod/telemetry/fire_tv_events_v1/view.sql
@ -269,6 +265,8 @@ format:
- sql/moz-fx-data-shared-prod/udf_legacy/date_trunc.sql
- sql/moz-fx-data-shared-prod/udf_legacy/to_iso8601.sql
- stored_procedures/safe_crc32_uuid.sql
skip_qualifying_references:
- sql/mozfun/**/examples/*.sql
routine:
dependency_dir: udf_js_lib/

Просмотреть файл

@ -60,7 +60,7 @@ WITH extracted_accumulated AS (
SELECT
*
FROM
glam_etl.firefox_desktop_glam_nightly__clients_histogram_aggregates_v1
`glam-fenix-dev.glam_etl.firefox_desktop_glam_nightly__clients_histogram_aggregates_v1`
WHERE
sample_id >= @min_sample_id
AND sample_id <= @max_sample_id
@ -78,7 +78,7 @@ filtered_accumulated AS (
FROM
extracted_accumulated
LEFT JOIN
glam_etl.firefox_desktop_glam_nightly__latest_versions_v1
`glam-fenix-dev.glam_etl.firefox_desktop_glam_nightly__latest_versions_v1`
USING (channel)
WHERE
-- allow for builds to be slighly ahead of the current submission date, to
@ -98,7 +98,7 @@ extracted_daily AS (
CAST(app_version AS INT64) AS app_version,
unnested_histogram_aggregates AS histogram_aggregates
FROM
glam_etl.firefox_desktop_glam_nightly__view_clients_daily_histogram_aggregates_v1,
`glam-fenix-dev.glam_etl.firefox_desktop_glam_nightly__view_clients_daily_histogram_aggregates_v1`,
UNNEST(histogram_aggregates) unnested_histogram_aggregates
WHERE
submission_date = @submission_date
@ -118,7 +118,7 @@ filtered_daily AS (
FROM
extracted_daily
LEFT JOIN
glam_etl.firefox_desktop_glam_nightly__latest_versions_v1
`glam-fenix-dev.glam_etl.firefox_desktop_glam_nightly__latest_versions_v1`
USING (channel)
WHERE
-- allow for builds to be slighly ahead of the current submission date, to

Просмотреть файл

@ -89,7 +89,7 @@ WITH filtered_date_channel AS (
SELECT
*
FROM
glam_etl.firefox_desktop_glam_nightly__view_clients_daily_scalar_aggregates_v1
`glam-fenix-dev.glam_etl.firefox_desktop_glam_nightly__view_clients_daily_scalar_aggregates_v1`
WHERE
submission_date = @submission_date
),
@ -131,7 +131,7 @@ version_filtered_new AS (
FROM
filtered_aggregates AS scalar_aggs
LEFT JOIN
glam_etl.firefox_desktop_glam_nightly__latest_versions_v1
`glam-fenix-dev.glam_etl.firefox_desktop_glam_nightly__latest_versions_v1`
USING (channel)
WHERE
-- allow for builds to be slighly ahead of the current submission date, to
@ -212,9 +212,9 @@ filtered_old AS (
scalar_aggs.channel,
scalar_aggregates
FROM
glam_etl.firefox_desktop_glam_nightly__clients_scalar_aggregates_v1 AS scalar_aggs
`glam-fenix-dev.glam_etl.firefox_desktop_glam_nightly__clients_scalar_aggregates_v1` AS scalar_aggs
LEFT JOIN
glam_etl.firefox_desktop_glam_nightly__latest_versions_v1
`glam-fenix-dev.glam_etl.firefox_desktop_glam_nightly__latest_versions_v1`
USING (channel)
WHERE
-- allow for builds to be slighly ahead of the current submission date, to

Просмотреть файл

@ -23,7 +23,7 @@ SELECT
IF(agg_type = "percentiles", mozfun.glam.histogram_cast_json(aggregates), NULL)
) AS percentiles,
FROM
`glam_etl.firefox_desktop_glam_nightly__view_probe_counts_v1`
`glam-fenix-dev.glam_etl.firefox_desktop_glam_nightly__view_probe_counts_v1`
WHERE
total_users > 10
GROUP BY

Просмотреть файл

@ -13,7 +13,7 @@ WITH deduped AS (
total_users DESC
) AS rank
FROM
`glam_etl.firefox_desktop_glam_nightly__view_user_counts_v1`
`glam-fenix-dev.glam_etl.firefox_desktop_glam_nightly__view_user_counts_v1`
)
SELECT
channel,

Просмотреть файл

@ -29,7 +29,7 @@ all_combos AS (
COALESCE(combo.os, table.os) AS os,
COALESCE(combo.app_build_id, table.app_build_id) AS app_build_id
FROM
glam_etl.firefox_desktop_glam_nightly__clients_histogram_aggregates_v1 table
`glam-fenix-dev.glam_etl.firefox_desktop_glam_nightly__clients_histogram_aggregates_v1` table
CROSS JOIN
static_combos combo
),

Просмотреть файл

@ -11,4 +11,4 @@ SELECT
('99.9', mozfun.glam.percentile(99.9, aggregates, metric_type))
] AS aggregates
FROM
glam_etl.firefox_desktop_glam_nightly__histogram_probe_counts_v1
`glam-fenix-dev.glam_etl.firefox_desktop_glam_nightly__histogram_probe_counts_v1`

Просмотреть файл

@ -56,7 +56,7 @@ SELECT
CAST(ROUND(SUM(record.value)) AS INT64)
) AS aggregates
FROM
glam_etl.firefox_desktop_glam_nightly__histogram_bucket_counts_v1
`glam-fenix-dev.glam_etl.firefox_desktop_glam_nightly__histogram_bucket_counts_v1`
GROUP BY
ping_type,
os,

Просмотреть файл

@ -5,7 +5,7 @@ WITH extracted AS (
channel,
app_version
FROM
glam_etl.firefox_desktop_glam_nightly__view_clients_daily_scalar_aggregates_v1
`glam-fenix-dev.glam_etl.firefox_desktop_glam_nightly__view_clients_daily_scalar_aggregates_v1`
WHERE
submission_date
BETWEEN DATE_SUB(@submission_date, INTERVAL 28 DAY)

Просмотреть файл

@ -104,7 +104,7 @@ all_combos AS (
COALESCE(combo.os, table.os) AS os,
COALESCE(combo.app_build_id, table.app_build_id) AS app_build_id
FROM
glam_etl.firefox_desktop_glam_nightly__clients_scalar_aggregates_v1 table
`glam-fenix-dev.glam_etl.firefox_desktop_glam_nightly__clients_scalar_aggregates_v1` table
CROSS JOIN
static_combos combo
),

Просмотреть файл

@ -3,7 +3,7 @@ WITH flat_clients_scalar_aggregates AS (
SELECT
* EXCEPT (scalar_aggregates)
FROM
glam_etl.firefox_desktop_glam_nightly__clients_scalar_aggregates_v1
`glam-fenix-dev.glam_etl.firefox_desktop_glam_nightly__clients_scalar_aggregates_v1`
CROSS JOIN
UNNEST(scalar_aggregates)
),

Просмотреть файл

@ -31,7 +31,7 @@ SELECT
SUM(count)
) AS aggregates
FROM
glam_etl.firefox_desktop_glam_nightly__scalar_bucket_counts_v1
`glam-fenix-dev.glam_etl.firefox_desktop_glam_nightly__scalar_bucket_counts_v1`
GROUP BY
ping_type,
os,

Просмотреть файл

@ -60,7 +60,7 @@ WITH extracted_accumulated AS (
SELECT
*
FROM
glam_etl.org_mozilla_fenix_glam_nightly__clients_histogram_aggregates_v1
`glam-fenix-dev.glam_etl.org_mozilla_fenix_glam_nightly__clients_histogram_aggregates_v1`
WHERE
sample_id >= @min_sample_id
AND sample_id <= @max_sample_id
@ -78,7 +78,7 @@ filtered_accumulated AS (
FROM
extracted_accumulated
LEFT JOIN
glam_etl.org_mozilla_fenix_glam_nightly__latest_versions_v1
`glam-fenix-dev.glam_etl.org_mozilla_fenix_glam_nightly__latest_versions_v1`
USING (channel)
WHERE
-- allow for builds to be slighly ahead of the current submission date, to
@ -98,7 +98,7 @@ extracted_daily AS (
CAST(app_version AS INT64) AS app_version,
unnested_histogram_aggregates AS histogram_aggregates
FROM
glam_etl.org_mozilla_fenix_glam_nightly__view_clients_daily_histogram_aggregates_v1,
`glam-fenix-dev.glam_etl.org_mozilla_fenix_glam_nightly__view_clients_daily_histogram_aggregates_v1`,
UNNEST(histogram_aggregates) unnested_histogram_aggregates
WHERE
submission_date = @submission_date
@ -118,7 +118,7 @@ filtered_daily AS (
FROM
extracted_daily
LEFT JOIN
glam_etl.org_mozilla_fenix_glam_nightly__latest_versions_v1
`glam-fenix-dev.glam_etl.org_mozilla_fenix_glam_nightly__latest_versions_v1`
USING (channel)
WHERE
-- allow for builds to be slighly ahead of the current submission date, to

Просмотреть файл

@ -89,7 +89,7 @@ WITH filtered_date_channel AS (
SELECT
*
FROM
glam_etl.org_mozilla_fenix_glam_nightly__view_clients_daily_scalar_aggregates_v1
`glam-fenix-dev.glam_etl.org_mozilla_fenix_glam_nightly__view_clients_daily_scalar_aggregates_v1`
WHERE
submission_date = @submission_date
),
@ -131,7 +131,7 @@ version_filtered_new AS (
FROM
filtered_aggregates AS scalar_aggs
LEFT JOIN
glam_etl.org_mozilla_fenix_glam_nightly__latest_versions_v1
`glam-fenix-dev.glam_etl.org_mozilla_fenix_glam_nightly__latest_versions_v1`
USING (channel)
WHERE
-- allow for builds to be slighly ahead of the current submission date, to
@ -212,9 +212,9 @@ filtered_old AS (
scalar_aggs.channel,
scalar_aggregates
FROM
glam_etl.org_mozilla_fenix_glam_nightly__clients_scalar_aggregates_v1 AS scalar_aggs
`glam-fenix-dev.glam_etl.org_mozilla_fenix_glam_nightly__clients_scalar_aggregates_v1` AS scalar_aggs
LEFT JOIN
glam_etl.org_mozilla_fenix_glam_nightly__latest_versions_v1
`glam-fenix-dev.glam_etl.org_mozilla_fenix_glam_nightly__latest_versions_v1`
USING (channel)
WHERE
-- allow for builds to be slighly ahead of the current submission date, to

Просмотреть файл

@ -23,7 +23,7 @@ SELECT
IF(agg_type = "percentiles", mozfun.glam.histogram_cast_json(aggregates), NULL)
) AS percentiles,
FROM
`glam_etl.org_mozilla_fenix_glam_nightly__view_probe_counts_v1`
`glam-fenix-dev.glam_etl.org_mozilla_fenix_glam_nightly__view_probe_counts_v1`
WHERE
total_users > 10
GROUP BY

Просмотреть файл

@ -13,7 +13,7 @@ WITH deduped AS (
total_users DESC
) AS rank
FROM
`glam_etl.org_mozilla_fenix_glam_nightly__view_user_counts_v1`
`glam-fenix-dev.glam_etl.org_mozilla_fenix_glam_nightly__view_user_counts_v1`
)
SELECT
channel,

Просмотреть файл

@ -29,7 +29,7 @@ all_combos AS (
COALESCE(combo.os, table.os) AS os,
COALESCE(combo.app_build_id, table.app_build_id) AS app_build_id
FROM
glam_etl.org_mozilla_fenix_glam_nightly__clients_histogram_aggregates_v1 table
`glam-fenix-dev.glam_etl.org_mozilla_fenix_glam_nightly__clients_histogram_aggregates_v1` table
CROSS JOIN
static_combos combo
),

Просмотреть файл

@ -9,4 +9,4 @@ SELECT
('95', mozfun.glam.percentile(95, aggregates, metric_type))
] AS aggregates
FROM
glam_etl.org_mozilla_fenix_glam_nightly__histogram_probe_counts_v1
`glam-fenix-dev.glam_etl.org_mozilla_fenix_glam_nightly__histogram_probe_counts_v1`

Просмотреть файл

@ -56,7 +56,7 @@ SELECT
CAST(ROUND(SUM(record.value)) AS INT64)
) AS aggregates
FROM
glam_etl.org_mozilla_fenix_glam_nightly__histogram_bucket_counts_v1
`glam-fenix-dev.glam_etl.org_mozilla_fenix_glam_nightly__histogram_bucket_counts_v1`
GROUP BY
ping_type,
os,

Просмотреть файл

@ -5,7 +5,7 @@ WITH extracted AS (
channel,
app_version
FROM
glam_etl.org_mozilla_fenix_glam_nightly__view_clients_daily_scalar_aggregates_v1
`glam-fenix-dev.glam_etl.org_mozilla_fenix_glam_nightly__view_clients_daily_scalar_aggregates_v1`
WHERE
submission_date
BETWEEN DATE_SUB(@submission_date, INTERVAL 28 DAY)

Просмотреть файл

@ -79,7 +79,7 @@ WITH build_ids AS (
app_build_id,
channel,
FROM
glam_etl.org_mozilla_fenix_glam_nightly__clients_scalar_aggregates_v1
`glam-fenix-dev.glam_etl.org_mozilla_fenix_glam_nightly__clients_scalar_aggregates_v1`
GROUP BY
app_build_id,
channel
@ -90,7 +90,7 @@ valid_clients_scalar_aggregates AS (
SELECT
*
FROM
glam_etl.org_mozilla_fenix_glam_nightly__clients_scalar_aggregates_v1
`glam-fenix-dev.glam_etl.org_mozilla_fenix_glam_nightly__clients_scalar_aggregates_v1`
INNER JOIN
build_ids
USING (app_build_id, channel)

Просмотреть файл

@ -3,7 +3,7 @@ WITH flat_clients_scalar_aggregates AS (
SELECT
* EXCEPT (scalar_aggregates)
FROM
glam_etl.org_mozilla_fenix_glam_nightly__clients_scalar_aggregates_v1
`glam-fenix-dev.glam_etl.org_mozilla_fenix_glam_nightly__clients_scalar_aggregates_v1`
CROSS JOIN
UNNEST(scalar_aggregates)
),

Просмотреть файл

@ -31,7 +31,7 @@ SELECT
SUM(count)
) AS aggregates
FROM
glam_etl.org_mozilla_fenix_glam_nightly__scalar_bucket_counts_v1
`glam-fenix-dev.glam_etl.org_mozilla_fenix_glam_nightly__scalar_bucket_counts_v1`
GROUP BY
ping_type,
os,

Просмотреть файл

@ -8,7 +8,7 @@ WITH recent_tests AS (
IFNULL(test_extra_options, '') AS test_extra_options,
IFNULL(subtest_name, '') AS subtest_name
FROM
rc_flattened_test_data_v1
`moz-fx-data-bq-performance.release_criteria.rc_flattened_test_data_v1`
WHERE
task_group_time >= TIMESTAMP_SUB(current_timestamp, INTERVAL 28 DAY)
),
@ -23,7 +23,7 @@ distinct_rc AS (
ARRAY_TO_STRING(ARRAY_AGG(DISTINCT rc_test_name), '\n') AS rc_test_name,
COUNT(*) AS defined_criteria
FROM
release_criteria_helper
`moz-fx-data-bq-performance.release_criteria.release_criteria_helper`
GROUP BY
framework,
platform,

Просмотреть файл

@ -26,13 +26,13 @@ WITH stage_1 AS (
SAFE_DIVIDE(rc_three_week_prior_average - rc_value, rc_value) AS three_week_pct_change,
SAFE_DIVIDE(rc_four_week_prior_average - rc_value, rc_value) AS four_week_pct_change,
FROM
release_criteria_v1 AS a
`moz-fx-data-bq-performance.release_criteria.release_criteria_v1` AS a
WHERE
task_group_time = (
SELECT
MAX(task_group_time)
FROM
release_criteria_v1 AS b
`moz-fx-data-bq-performance.release_criteria.release_criteria_v1` AS b
WHERE
a.project = b.project
AND a.platform = b.platform

Просмотреть файл

@ -11,7 +11,7 @@ WITH rc_included_tests AS (
IFNULL(test_extra_options, '') AS test_extra_options
)
FROM
release_criteria_helper
`moz-fx-data-bq-performance.release_criteria.release_criteria_helper`
WHERE
rc_test_name IS NOT NULL
AND rc_test_name != 'exclude'
@ -38,7 +38,7 @@ rc_test_data AS (
included_rc.rc_target_value,
included_rc.rc_target_app,
FROM
rc_flattened_test_data_v1 AS flattened
`moz-fx-data-bq-performance.release_criteria.rc_flattened_test_data_v1` AS flattened
LEFT JOIN
rc_included_tests AS included_rc
ON flattened.framework = included_rc.framework

Просмотреть файл

@ -6,14 +6,14 @@ SELECT DISTINCT
rc_test_name,
task_group_time
FROM
release_criteria_v1 AS a
`moz-fx-data-bq-performance.release_criteria.release_criteria_v1` AS a
WHERE
`moz-fx-data-bq-performance.udf.is_stale_test`(task_group_time, test_tier)
AND task_group_time = (
SELECT
MAX(task_group_time)
FROM
release_criteria_v1 AS b
`moz-fx-data-bq-performance.release_criteria.release_criteria_v1` AS b
WHERE
a.project = b.project
AND a.platform = b.platform

Просмотреть файл

@ -69,7 +69,7 @@ windowed AS (
submission_timestamp,
user_id_sha256,
service,
udf.mode_last(ARRAY_AGG(country) OVER w1) AS country,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(country) OVER w1) AS country,
udf_contains_tier1_country(ARRAY_AGG(country) OVER w1) AS seen_in_tier1_country,
LOGICAL_OR(event_name = 'reg_complete') OVER w1 AS registered,
-- we cannot count distinct here because the window is ordered by submission_timestamp

Просмотреть файл

@ -12,7 +12,7 @@ WITH _current AS (
CAST(registered AS INT64) AS days_registered_bits,
* EXCEPT (submission_date, registered, seen_in_tier1_country),
FROM
accounts_backend_derived.users_services_daily_v1
`moz-fx-data-shared-prod.accounts_backend_derived.users_services_daily_v1`
WHERE
submission_date = @submission_date
),
@ -28,24 +28,24 @@ _previous AS (
submission_date
)
FROM
accounts_backend_derived.users_services_last_seen_v1
`moz-fx-data-shared-prod.accounts_backend_derived.users_services_last_seen_v1`
WHERE
submission_date = DATE_SUB(@submission_date, INTERVAL 1 DAY)
-- Filter out rows from yesterday that have now fallen outside the 28-day window.
AND udf.shift_28_bits_one_day(days_seen_bits) > 0
AND `moz-fx-data-shared-prod.udf.shift_28_bits_one_day`(days_seen_bits) > 0
)
SELECT
@submission_date AS submission_date,
IF(_current.user_id_sha256 IS NOT NULL, _current, _previous).* REPLACE (
udf.combine_adjacent_days_28_bits(
`moz-fx-data-shared-prod.udf.combine_adjacent_days_28_bits`(
_previous.days_seen_bits,
_current.days_seen_bits
) AS days_seen_bits,
udf.combine_adjacent_days_28_bits(
`moz-fx-data-shared-prod.udf.combine_adjacent_days_28_bits`(
_previous.days_seen_in_tier1_country_bits,
_current.days_seen_in_tier1_country_bits
) AS days_seen_in_tier1_country_bits,
udf.coalesce_adjacent_days_28_bits(
`moz-fx-data-shared-prod.udf.coalesce_adjacent_days_28_bits`(
_previous.days_registered_bits,
_current.days_registered_bits
) AS days_registered_bits

Просмотреть файл

@ -11,7 +11,7 @@ SELECT
tile_id,
user_prefs,
FROM
activity_stream_bi.impression_stats_flat_v1
`moz-fx-data-shared-prod.activity_stream_bi.impression_stats_flat_v1`
CROSS JOIN
UNNEST(experiments) AS experiment
WHERE

Просмотреть файл

@ -23,7 +23,7 @@ SELECT
ANY_VALUE(experiments) AS experiments,
sample_id
FROM
activity_stream_stable.impression_stats_v1
`moz-fx-data-shared-prod.activity_stream_stable.impression_stats_v1`
CROSS JOIN
UNNEST(tiles) AS flattened_tiles
WITH OFFSET AS alt_pos

Просмотреть файл

@ -7,7 +7,7 @@ Reduced stats table for dev and stage versions of the AMO service.
SELECT
*
FROM
amo_prod.amo_stats_dau_v2
`moz-fx-data-shared-prod.amo_prod.amo_stats_dau_v2`
WHERE
submission_date = @submission_date
AND (

Просмотреть файл

@ -6,12 +6,12 @@ WITH addon_id_lookup AS (
addon_id,
TO_HEX(SHA256(addon_id)) AS hashed_addon_id
FROM
amo_dev.amo_stats_dau_v2
`moz-fx-data-shared-prod.amo_dev.amo_stats_dau_v2`
)
SELECT
installs.*
FROM
amo_prod.amo_stats_installs_v3 AS installs
`moz-fx-data-shared-prod.amo_prod.amo_stats_installs_v3` AS installs
-- This join will filter out all addon_ids that are not already present
-- in the dev dau table, so we don't need to duplicate the list of addons
-- approved for dev here.

Просмотреть файл

@ -13,13 +13,13 @@ WITH unioned AS (
*,
'Desktop' AS app
FROM
amo_prod.desktop_addons_by_client_v1
`moz-fx-data-shared-prod.amo_prod.desktop_addons_by_client_v1`
UNION ALL
SELECT
*,
'Fenix' AS app
FROM
amo_prod.fenix_addons_by_client_v1
`moz-fx-data-shared-prod.amo_prod.fenix_addons_by_client_v1`
),
unnested AS (
SELECT

Просмотреть файл

@ -8,7 +8,7 @@ WITH install_stats AS (
mozfun.map.get_key(event_map_values, 'utm_source') AS utm_source,
mozfun.map.get_key(event_map_values, 'utm_medium') AS utm_medium,
FROM
telemetry.events
`moz-fx-data-shared-prod.telemetry.events`
WHERE
event_category = 'addonsManager'
AND event_method = 'install_stats'

Просмотреть файл

@ -26,7 +26,7 @@ WITH filtered_main AS (
environment.settings.locale,
normalized_os
FROM
telemetry.main
`moz-fx-data-shared-prod.telemetry.main`
WHERE
DATE(submission_timestamp) = @submission_date
AND client_id IS NOT NULL

Просмотреть файл

@ -15,14 +15,14 @@ WITH unioned AS (
get_fields(release).*,
client_info.app_display_version AS app_version,
FROM
org_mozilla_firefox.metrics AS release
`moz-fx-data-shared-prod.org_mozilla_firefox.metrics` AS release
UNION ALL
SELECT
get_fields(beta).*,
-- Bug 1669516 We choose to show beta versions as 80.0.0b1, etc.
REPLACE(client_info.app_display_version, '-beta.', 'b') AS app_version,
FROM
org_mozilla_firefox_beta.metrics AS beta
`moz-fx-data-shared-prod.org_mozilla_firefox_beta.metrics` AS beta
UNION ALL
SELECT
get_fields(nightly).*,
@ -30,19 +30,19 @@ WITH unioned AS (
-- so we take the geckoview version instead.
nightly.metrics.string.geckoview_version AS app_version,
FROM
org_mozilla_fenix.metrics AS nightly
`moz-fx-data-shared-prod.org_mozilla_fenix.metrics` AS nightly
UNION ALL
SELECT
get_fields(preview_nightly).*,
preview_nightly.metrics.string.geckoview_version AS app_version,
FROM
org_mozilla_fenix_nightly.metrics AS preview_nightly
`moz-fx-data-shared-prod.org_mozilla_fenix_nightly.metrics` AS preview_nightly
UNION ALL
SELECT
get_fields(old_fenix_nightly).*,
old_fenix_nightly.metrics.string.geckoview_version AS app_version,
FROM
org_mozilla_fennec_aurora.metrics AS old_fenix_nightly
`moz-fx-data-shared-prod.org_mozilla_fennec_aurora.metrics` AS old_fenix_nightly
),
cleaned AS (
SELECT
@ -68,9 +68,9 @@ per_client AS (
ARRAY_AGG(app_version ORDER BY mozfun.norm.truncate_version(app_version, "minor") DESC)[
SAFE_OFFSET(0)
] AS app_version,
udf.mode_last(ARRAY_AGG(normalized_country_code)) AS country,
udf.mode_last(ARRAY_AGG(locale)) AS locale,
udf.mode_last(ARRAY_AGG(normalized_os)) AS app_os,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(normalized_country_code)) AS country,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(locale)) AS locale,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(normalized_os)) AS app_os,
FROM
cleaned
WHERE

Просмотреть файл

@ -17,7 +17,7 @@ WITH daily_stats AS (
SUM(redownloads) AS redownloads,
SUM(total_downloads) AS total_downloads
FROM
apple_ads.ad_group_report
`moz-fx-data-shared-prod.apple_ads.ad_group_report`
GROUP BY
date_day,
campaign_name,
@ -39,7 +39,7 @@ activations AS (
FROM
`mozdata.ltv.firefox_ios_client_ltv` ltv
INNER JOIN
firefox_ios.firefox_ios_clients cl
`moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients` cl
ON ltv.client_id = cl.client_id
AND ltv.sample_id = cl.sample_id
WHERE
@ -57,7 +57,7 @@ retention_aggs AS (
SUM(repeat_user) AS repeat_users,
SUM(retained_week_4) AS retained_week_4
FROM
firefox_ios.funnel_retention_week_4
`moz-fx-data-shared-prod.firefox_ios.funnel_retention_week_4`
GROUP BY
`date`,
campaign_id,

Просмотреть файл

@ -63,7 +63,7 @@ WITH client_counts AS (
END
) AS eligible_clients
FROM
telemetry.unified_metrics
`moz-fx-data-shared-prod.telemetry.unified_metrics`
WHERE
mozfun.bits28.active_in_range(days_seen_bits, 0, 1)
AND submission_date >= "2021-09-07"
@ -123,7 +123,7 @@ tiles_percentages AS (
END
) / NULLIF(SUM(user_count), 0) AS p_other
FROM
contextual_services.event_aggregates
`moz-fx-data-shared-prod.contextual_services.event_aggregates`
WHERE
submission_date >= "2021-09-07"
AND release_channel = "release"
@ -157,7 +157,7 @@ suggest_percentages AS (
END
) AS other_dou,
FROM
contextual_services.event_aggregates
`moz-fx-data-shared-prod.contextual_services.event_aggregates`
WHERE
submission_date >= "2022-06-07"
AND release_channel = "release"
@ -180,7 +180,7 @@ desktop_population AS (
"desktop" AS device,
COUNT(DISTINCT client_id) AS clients
FROM
telemetry.clients_daily
`moz-fx-data-shared-prod.telemetry.clients_daily`
CROSS JOIN
UNNEST(experiments) AS experiment
WHERE
@ -235,7 +235,7 @@ desktop_population AS (
"desktop" AS device,
COUNT(DISTINCT client_id) AS clients
FROM
telemetry.clients_daily
`moz-fx-data-shared-prod.telemetry.clients_daily`
CROSS JOIN
UNNEST(experiments) AS experiment
WHERE
@ -289,7 +289,7 @@ daily_mobile_clients AS (
client_id,
country
FROM
telemetry.unified_metrics AS browser_dau
`moz-fx-data-shared-prod.telemetry.unified_metrics` AS browser_dau
WHERE
mozfun.bits28.active_in_range(browser_dau.days_seen_bits, 0, 1)
-- don't want Focus apps
@ -316,7 +316,7 @@ daily_mobile_clients AS (
submission_date,
country
FROM
telemetry.unified_metrics AS browser_dau
`moz-fx-data-shared-prod.telemetry.unified_metrics` AS browser_dau
WHERE
mozfun.bits28.active_in_range(browser_dau.days_seen_bits, 0, 1)
-- don't want Focus apps
@ -400,7 +400,7 @@ clicks AS (
0
) AS other_clicks
FROM
contextual_services.event_aggregates
`moz-fx-data-shared-prod.contextual_services.event_aggregates`
WHERE
submission_date >= "2021-09-07"
AND release_channel = "release"
@ -428,7 +428,7 @@ clicks AS (
0
) AS other_clicks
FROM
contextual_services.event_aggregates
`moz-fx-data-shared-prod.contextual_services.event_aggregates`
WHERE
submission_date >= "2022-06-07"
AND release_channel = "release"

Просмотреть файл

@ -35,7 +35,7 @@ combined AS (
(metrics.boolean.quick_suggest_improve_suggest_experience) AS suggest_data_sharing_enabled,
blocks.query_type,
FROM
firefox_desktop.quick_suggest qs
`moz-fx-data-shared-prod.firefox_desktop.quick_suggest` qs
LEFT JOIN
blocks
ON SAFE_CAST(qs.metrics.string.quick_suggest_block_id AS INT) = blocks.id
@ -68,9 +68,9 @@ combined AS (
) AS suggest_data_sharing_enabled,
CAST(NULL AS STRING) AS query_type,
FROM
contextual_services.quicksuggest_impression
`moz-fx-data-shared-prod.contextual_services.quicksuggest_impression`
WHERE
-- For firefox 116+ use firefox_desktop.quick_suggest instead
-- For firefox 116+ use `moz-fx-data-shared-prod.firefox_desktop.quick_suggest` instead
-- https://bugzilla.mozilla.org/show_bug.cgi?id=1836283
SAFE_CAST(metadata.user_agent.version AS INT64) < 116
UNION ALL
@ -100,9 +100,9 @@ combined AS (
) AS suggest_data_sharing_enabled,
CAST(NULL AS STRING) AS query_type,
FROM
contextual_services.quicksuggest_click
`moz-fx-data-shared-prod.contextual_services.quicksuggest_click`
WHERE
-- For firefox 116+ use firefox_desktop.quick_suggest instead
-- For firefox 116+ use `moz-fx-data-shared-prod.firefox_desktop.quick_suggest` instead
-- https://bugzilla.mozilla.org/show_bug.cgi?id=1836283
SAFE_CAST(metadata.user_agent.version AS INT64) < 116
UNION ALL
@ -195,7 +195,7 @@ combined AS (
CAST(NULL AS BOOLEAN) AS suggest_data_sharing_enabled,
CAST(NULL AS STRING) AS query_type,
FROM
firefox_desktop.top_sites
`moz-fx-data-shared-prod.firefox_desktop.top_sites`
WHERE
metrics.string.top_sites_ping_type IN ("topsites-click", "topsites-impression")
UNION ALL
@ -222,9 +222,9 @@ combined AS (
NULL AS suggest_data_sharing_enabled,
CAST(NULL AS STRING) AS query_type,
FROM
contextual_services.topsites_impression
`moz-fx-data-shared-prod.contextual_services.topsites_impression`
WHERE
-- For firefox 116+ use firefox_desktop.top_sites instead
-- For firefox 116+ use `moz-fx-data-shared-prod.firefox_desktop.top_sites` instead
-- https://bugzilla.mozilla.org/show_bug.cgi?id=1836283
SAFE_CAST(metadata.user_agent.version AS INT64) < 116
UNION ALL
@ -251,9 +251,9 @@ combined AS (
NULL AS suggest_data_sharing_enabled,
CAST(NULL AS STRING) AS query_type,
FROM
contextual_services.topsites_click
`moz-fx-data-shared-prod.contextual_services.topsites_click`
WHERE
-- For firefox 116+ use firefox_desktop.top_sites instead
-- For firefox 116+ use `moz-fx-data-shared-prod.firefox_desktop.top_sites` instead
-- https://bugzilla.mozilla.org/show_bug.cgi?id=1836283
SAFE_CAST(metadata.user_agent.version AS INT64) < 116
UNION ALL
@ -281,7 +281,7 @@ combined AS (
NULL AS suggest_data_sharing_enabled,
CAST(NULL AS STRING) AS query_type,
FROM
org_mozilla_firefox.topsites_impression
`moz-fx-data-shared-prod.org_mozilla_firefox.topsites_impression`
UNION ALL
SELECT
metrics.uuid.top_sites_context_id AS context_id,
@ -305,7 +305,7 @@ combined AS (
NULL AS suggest_data_sharing_enabled,
CAST(NULL AS STRING) AS query_type,
FROM
org_mozilla_firefox_beta.topsites_impression
`moz-fx-data-shared-prod.org_mozilla_firefox_beta.topsites_impression`
UNION ALL
SELECT
metrics.uuid.top_sites_context_id AS context_id,
@ -329,7 +329,7 @@ combined AS (
NULL AS suggest_data_sharing_enabled,
CAST(NULL AS STRING) AS query_type,
FROM
org_mozilla_fenix.topsites_impression
`moz-fx-data-shared-prod.org_mozilla_fenix.topsites_impression`
UNION ALL
SELECT
-- Due to the renaming (from 'topsite' to 'topsites'), some legacy Firefox
@ -362,7 +362,7 @@ combined AS (
NULL AS suggest_data_sharing_enabled,
CAST(NULL AS STRING) AS query_type,
FROM
org_mozilla_ios_firefox.topsites_impression
`moz-fx-data-shared-prod.org_mozilla_ios_firefox.topsites_impression`
UNION ALL
SELECT
-- Due to the renaming (from 'topsite' to 'topsites'), some legacy Firefox
@ -395,7 +395,7 @@ combined AS (
NULL AS suggest_data_sharing_enabled,
CAST(NULL AS STRING) AS query_type,
FROM
org_mozilla_ios_firefoxbeta.topsites_impression
`moz-fx-data-shared-prod.org_mozilla_ios_firefoxbeta.topsites_impression`
),
with_event_count AS (
SELECT

Просмотреть файл

@ -1,7 +1,9 @@
WITH parsed AS (
SELECT
submission_timestamp,
udf_js.parse_sponsored_interaction(udf_js.extract_string_from_bytes(payload)) AS si
`moz-fx-data-shared-prod.udf_js.parse_sponsored_interaction`(
`moz-fx-data-shared-prod.udf_js.extract_string_from_bytes`(payload)
) AS si
FROM
`moz-fx-data-shared-prod.payload_bytes_error.contextual_services`
WHERE

Просмотреть файл

@ -1,7 +1,9 @@
WITH parsed AS (
SELECT
submission_timestamp,
udf_js.parse_sponsored_interaction(udf_js.extract_string_from_bytes(payload)) AS si
`moz-fx-data-shared-prod.udf_js.parse_sponsored_interaction`(
`moz-fx-data-shared-prod.udf_js.extract_string_from_bytes`(payload)
) AS si
FROM
`moz-fx-data-shared-prod.payload_bytes_error.contextual_services`
WHERE

Просмотреть файл

@ -27,7 +27,7 @@ WITH client_shares AS (
END
) AS eligible_clients
FROM
telemetry.unified_metrics
`moz-fx-data-shared-prod.telemetry.unified_metrics`
WHERE
mozfun.bits28.active_in_range(days_seen_bits, 0, 1)
AND submission_date >= "2022-06-07"
@ -55,7 +55,7 @@ suggest_clients AS (
submission_date,
COUNT(client_id) AS live_market_dau
FROM
telemetry.unified_metrics
`moz-fx-data-shared-prod.telemetry.unified_metrics`
WHERE
mozfun.bits28.active_in_range(days_seen_bits, 0, 1)
AND submission_date >= "2022-06-07"
@ -78,7 +78,7 @@ search_clients AS (
SUM(CASE WHEN SOURCE LIKE "urlbar%" THEN sap ELSE 0 END) AS urlbar_search,
MAX(COALESCE(SOURCE LIKE "urlbar%", FALSE)) AS did_urlbar_search,
FROM
search.search_clients_engines_sources_daily
`moz-fx-data-shared-prod.search.search_clients_engines_sources_daily`
WHERE
submission_date >= "2022-06-07"
AND browser_version_info.major_version >= 92
@ -123,7 +123,7 @@ desktop_population AS (
SUM(impression_sponsored_count) AS spons_impressions,
SUM(click_sponsored_count) AS spons_clicks
FROM
telemetry.suggest_clients_daily
`moz-fx-data-shared-prod.telemetry.suggest_clients_daily`
WHERE
submission_date >= "2022-06-07"
GROUP BY

Просмотреть файл

@ -20,7 +20,7 @@ historic_data AS (
SELECT
*
FROM
fenix_derived.client_ltv_v1
`moz-fx-data-shared-prod.fenix_derived.client_ltv_v1`
)
SELECT
(

Просмотреть файл

@ -3,7 +3,7 @@
CAST(NULL AS BYTES) AS days_seen_bytes,
* EXCEPT (normalized_app_id),
FROM
fenix.baseline_clients_daily
`moz-fx-data-shared-prod.fenix.baseline_clients_daily`
WHERE
-- Output empty table and read no input rows
FALSE
@ -22,7 +22,7 @@
first_run_date ASC
) AS rn,
FROM
fenix.baseline_clients_daily
`moz-fx-data-shared-prod.fenix.baseline_clients_daily`
WHERE
submission_date = @submission_date
),
@ -31,7 +31,7 @@
-- In this raw table, we capture the history of activity over the past
-- 365 days for each usage criterion as an array of bytes. The
-- rightmost bit represents whether the user was active in the current day.
udf.bool_to_365_bits(TRUE) AS days_seen_bytes,
`moz-fx-data-shared-prod.udf.bool_to_365_bits`(TRUE) AS days_seen_bytes,
-- We explicitly pull out the fields specified in schema.yaml
client_id,
sample_id,
@ -67,16 +67,16 @@
SELECT
* EXCEPT (submission_date)
FROM
fenix_derived.clients_yearly_v1
`moz-fx-data-shared-prod.fenix_derived.clients_yearly_v1`
WHERE
submission_date = DATE_SUB(@submission_date, INTERVAL 1 DAY)
-- Filter out rows from yesterday that have now fallen outside the 365-day window.
AND BIT_COUNT(udf.shift_365_bits_one_day(days_seen_bytes)) > 0
AND BIT_COUNT(`moz-fx-data-shared-prod.udf.shift_365_bits_one_day`(days_seen_bytes)) > 0
)
SELECT
@submission_date AS submission_date,
IF(_current.client_id IS NOT NULL, _current, _previous).* REPLACE (
udf.combine_adjacent_days_365_bits(
`moz-fx-data-shared-prod.udf.combine_adjacent_days_365_bits`(
_previous.days_seen_bytes,
_current.days_seen_bytes
) AS days_seen_bytes

Просмотреть файл

@ -7,7 +7,7 @@ WITH baseline_clients AS (
normalized_channel AS channel,
normalized_country_code AS country
FROM
fenix.baseline
`moz-fx-data-shared-prod.fenix.baseline`
WHERE
metrics.timespan.glean_baseline_duration.value > 0
AND LOWER(metadata.isp.name) <> "browserstack"
@ -31,7 +31,7 @@ client_attribution AS (
channel,
adjust_network,
FROM
fenix.firefox_android_clients
`moz-fx-data-shared-prod.fenix.firefox_android_clients`
),
default_browser AS (
SELECT
@ -45,7 +45,7 @@ default_browser AS (
normalized_country_code AS country,
COALESCE(metrics.boolean.metrics_default_browser, FALSE) AS is_default_browser,
FROM
fenix.metrics AS metric_ping
`moz-fx-data-shared-prod.fenix.metrics` AS metric_ping
WHERE
LOWER(metadata.isp.name) <> "browserstack"
-- we need to work with a larger time window as some metrics ping arrive with a multi day delay
@ -332,7 +332,7 @@ event_ping_clients_feature_usage AS (
AND event_name = 'customize_home_clicked'
) AS home_page_customize_home_clicked
FROM
fenix.events_unnested
`moz-fx-data-shared-prod.fenix.events_unnested`
WHERE
DATE(submission_timestamp)
BETWEEN DATE_SUB(@submission_date, INTERVAL 4 DAY)

Просмотреть файл

@ -7,7 +7,7 @@ WITH baseline_clients AS (
normalized_channel AS channel,
normalized_country_code AS country,
FROM
fenix.baseline
`moz-fx-data-shared-prod.fenix.baseline`
WHERE
DATE(submission_timestamp)
BETWEEN DATE_SUB(@submission_date, INTERVAL 4 DAY)
@ -31,7 +31,7 @@ client_attribution AS (
channel,
adjust_network,
FROM
fenix.firefox_android_clients
`moz-fx-data-shared-prod.fenix.firefox_android_clients`
),
metric_ping_clients_feature_usage AS (
SELECT
@ -122,7 +122,7 @@ metric_ping_clients_feature_usage AS (
COUNTIF(metrics.boolean.customize_home_recently_saved) AS customize_home_recently_saved,
COUNTIF(metrics.boolean.customize_home_recently_visited) AS customize_home_recently_visited
FROM
fenix.metrics AS metric
`moz-fx-data-shared-prod.fenix.metrics` AS metric
LEFT JOIN
UNNEST(metrics.labeled_counter.metrics_bookmarks_add) AS metrics_bookmarks_add_table
LEFT JOIN

Просмотреть файл

@ -87,7 +87,7 @@ first_session_ping_min_seq AS (
submission_timestamp
) AS RANK
FROM
fenix.first_session AS fenix_first_session
`moz-fx-data-shared-prod.fenix.first_session` AS fenix_first_session
WHERE
ping_info.seq IS NOT NULL
AND
@ -159,7 +159,7 @@ first_session_ping AS (
SAFE_OFFSET(0)
] AS meta_attribution_app,
FROM
fenix.first_session AS fenix_first_session
`moz-fx-data-shared-prod.fenix.first_session` AS fenix_first_session
LEFT JOIN
first_session_ping_min_seq
ON (
@ -228,7 +228,7 @@ metrics_ping AS (
submission_timestamp DESC
)[SAFE_OFFSET(0)] AS last_reported_adjust_campaign,
FROM
fenix.metrics AS fenix_metrics
`moz-fx-data-shared-prod.fenix.metrics` AS fenix_metrics
WHERE
{% if is_init() %}
DATE(submission_timestamp) >= "2020-08-01"

Просмотреть файл

@ -5,7 +5,7 @@ WITH clients_retention AS (
sample_id,
days_seen_bits,
FROM
fenix.baseline_clients_last_seen
`moz-fx-data-shared-prod.fenix.baseline_clients_last_seen`
WHERE
submission_date = @submission_date
AND normalized_channel = "release"
@ -23,7 +23,7 @@ clients_first_seen AS (
adjust_network,
install_source,
FROM
fenix.firefox_android_clients
`moz-fx-data-shared-prod.fenix.firefox_android_clients`
WHERE
-- Two weeks need to elapse before calculating the week 2 retention
first_seen_date = DATE_SUB(@submission_date, INTERVAL 13 DAY)

Просмотреть файл

@ -5,7 +5,7 @@ WITH clients_retention AS (
sample_id,
days_seen_bits,
FROM
fenix.baseline_clients_last_seen
`moz-fx-data-shared-prod.fenix.baseline_clients_last_seen`
WHERE
submission_date = @submission_date
AND normalized_channel = "release"
@ -23,7 +23,7 @@ clients_first_seen AS (
adjust_network,
install_source,
FROM
fenix.firefox_android_clients
`moz-fx-data-shared-prod.fenix.firefox_android_clients`
WHERE
-- 28 days need to elapse before calculating the week 4 and day 28 retention metrics
first_seen_date = DATE_SUB(@submission_date, INTERVAL 27 DAY)

Просмотреть файл

@ -12,7 +12,7 @@ SELECT
COUNTIF(repeat_first_month_user) AS repeat_user,
COUNTIF(retained_week_4) AS retained_week_4,
FROM
fenix_derived.funnel_retention_clients_week_4_v1
`moz-fx-data-shared-prod.fenix_derived.funnel_retention_clients_week_4_v1`
WHERE
submission_date = @submission_date
GROUP BY

Просмотреть файл

@ -9,7 +9,7 @@
SELECT
mozfun.assert.equals(1, COUNT(DISTINCT state_function))
FROM
fenix_derived.ltv_state_values_v1
`moz-fx-data-shared-prod.fenix_derived.ltv_state_values_v1`
GROUP BY
country;
@ -18,4 +18,4 @@ GROUP BY
SELECT
`mozfun.assert.true`(COUNT(DISTINCT country) > 2)
FROM
fenix_derived.ltv_state_values_v1;
`moz-fx-data-shared-prod.fenix_derived.ltv_state_values_v1`;

Просмотреть файл

@ -9,7 +9,7 @@
SELECT
mozfun.assert.equals(1, COUNT(DISTINCT state_function))
FROM
fenix_derived.ltv_state_values_v1
`moz-fx-data-shared-prod.fenix_derived.ltv_state_values_v1`
GROUP BY
country;
@ -18,4 +18,4 @@ GROUP BY
SELECT
`mozfun.assert.true`(COUNT(DISTINCT country) > 2)
FROM
fenix_derived.ltv_state_values_v1;
`moz-fx-data-shared-prod.fenix_derived.ltv_state_values_v1`;

Просмотреть файл

@ -9,7 +9,7 @@ WITH clients_yearly AS (
consecutive_days_seen,
days_seen_bytes,
FROM
fenix.clients_yearly
`moz-fx-data-shared-prod.fenix.clients_yearly`
WHERE
{% if is_init() %}
submission_date >= "2010-01-01"
@ -49,10 +49,10 @@ SELECT
FROM
clients_yearly
JOIN
fenix.firefox_android_clients
`moz-fx-data-shared-prod.fenix.firefox_android_clients` AS firefox_android_clients
USING (sample_id, client_id)
LEFT JOIN
fenix.client_adclicks_history
`moz-fx-data-shared-prod.fenix.client_adclicks_history`
USING (sample_id, client_id)
WHERE
-- BrowserStack clients are bots, we don't want to accidentally report on them

Просмотреть файл

@ -13,7 +13,7 @@ SELECT
metadata.geo.country AS country,
COUNT(*) AS ping_count
FROM
fenix.first_session
`moz-fx-data-shared-prod.fenix.first_session`
WHERE
{% if is_init() %}
DATE(submission_timestamp) >= '2023-11-01'

Просмотреть файл

@ -13,7 +13,7 @@ backfill AS (
) AS days_since_seen_in_tier1_country,
country
FROM
static.fxa_amplitude_export_users_last_seen
`moz-fx-data-shared-prod.static.fxa_amplitude_export_users_last_seen`
WHERE
submission_date < DATE '2019-03-28'
),
@ -27,7 +27,7 @@ live AS (
days_since_seen_in_tier1_country,
country
FROM
firefox_accounts.fxa_users_last_seen
`moz-fx-data-shared-prod.firefox_accounts.fxa_users_last_seen`
WHERE
submission_date >= DATE '2019-03-28'
),

Просмотреть файл

@ -39,7 +39,10 @@ grouped_by_user AS (
-- to prevent weirdness from timestamp field, use provided
-- submission date parameter as timestamp
TO_HEX(
udf.hmac_sha256((SELECT * FROM hmac_key), CAST(jsonPayload.fields.user_id AS BYTES))
`moz-fx-data-shared-prod.udf.hmac_sha256`(
(SELECT * FROM hmac_key),
CAST(jsonPayload.fields.user_id AS BYTES)
)
) AS user_id,
MIN(CONCAT(insertId, '-user')) AS insert_id,
-- Amplitude properties, scalars
@ -114,20 +117,20 @@ _previous AS (
SELECT
* EXCEPT (submission_date_pacific)
FROM
firefox_accounts_derived.fxa_amplitude_export_v1
`moz-fx-data-shared-prod.firefox_accounts_derived.fxa_amplitude_export_v1`
WHERE
submission_date_pacific = DATE_SUB(@submission_date, INTERVAL 1 DAY)
AND udf.shift_28_bits_one_day(days_seen_bits) > 0
AND `moz-fx-data-shared-prod.udf.shift_28_bits_one_day`(days_seen_bits) > 0
)
SELECT
@submission_date AS submission_date_pacific,
_current.* REPLACE (
COALESCE(_current.user_id, _previous.user_id) AS user_id,
udf.combine_adjacent_days_28_bits(
`moz-fx-data-shared-prod.udf.combine_adjacent_days_28_bits`(
_previous.days_seen_bits,
_current.days_seen_bits
) AS days_seen_bits,
udf.combine_days_seen_maps(
`moz-fx-data-shared-prod.udf.combine_days_seen_maps`(
_previous.os_used_month,
ARRAY(SELECT STRUCT(key, CAST(TRUE AS INT64) AS value) FROM _current.os_used_month AS key)
) AS os_used_month

Просмотреть файл

@ -12,7 +12,10 @@ WITH hmac_key AS (
)
SELECT
TO_HEX(
udf.hmac_sha256((SELECT * FROM hmac_key), CAST(jsonPayload.fields.user_id AS BYTES))
`moz-fx-data-shared-prod.udf.hmac_sha256`(
(SELECT * FROM hmac_key),
CAST(jsonPayload.fields.user_id AS BYTES)
)
) AS user_id
FROM
`moz-fx-fxa-prod-0712.fxa_prod_logs.docker_fxa_auth`
@ -23,5 +26,5 @@ FROM
SELECT
user_id
FROM
fxa_amplitude_user_ids_v1
`moz-fx-data-shared-prod.firefox_accounts_derived.fxa_amplitude_user_ids_v1`
{% endif %}

Просмотреть файл

@ -14,7 +14,10 @@ SELECT
`timestamp` AS submission_timestamp,
TO_HEX(SHA256(jsonPayload.fields.uid)) AS user_id,
TO_HEX(
udf.hmac_sha256((SELECT * FROM hmac_key), CAST(jsonPayload.fields.uid AS BYTES))
`moz-fx-data-shared-prod.udf.hmac_sha256`(
(SELECT * FROM hmac_key),
CAST(jsonPayload.fields.uid AS BYTES)
)
) AS hmac_user_id,
FROM
`moz-fx-fxa-prod-0712.fxa_prod_logs.docker_fxa_auth`

Просмотреть файл

@ -14,7 +14,10 @@ SELECT
MIN(`timestamp`) AS submission_timestamp,
TO_HEX(SHA256(jsonPayload.fields.uid)) AS user_id,
TO_HEX(
udf.hmac_sha256((SELECT * FROM hmac_key), CAST(jsonPayload.fields.uid AS BYTES))
`moz-fx-data-shared-prod.udf.hmac_sha256`(
(SELECT * FROM hmac_key),
CAST(jsonPayload.fields.uid AS BYTES)
)
) AS hmac_user_id,
FROM
`moz-fx-fxa-prod.gke_fxa_prod_log.stderr`

Просмотреть файл

@ -15,22 +15,31 @@ SELECT
`timestamp`,
jsonPayload.type,
TO_HEX(
udf.hmac_sha256((SELECT * FROM hmac_key), CAST(jsonPayload.fields.uid AS BYTES))
`moz-fx-data-shared-prod.udf.hmac_sha256`(
(SELECT * FROM hmac_key),
CAST(jsonPayload.fields.uid AS BYTES)
)
) AS user_id,
TO_HEX(
udf.hmac_sha256(
`moz-fx-data-shared-prod.udf.hmac_sha256`(
(SELECT * FROM hmac_key),
CAST(FORMAT('%d', CAST(jsonPayload.fields.index AS INT64)) AS BYTES)
)
) AS index,
jsonPayload.fields.command,
TO_HEX(
udf.hmac_sha256((SELECT * FROM hmac_key), CAST(jsonPayload.fields.target AS BYTES))
`moz-fx-data-shared-prod.udf.hmac_sha256`(
(SELECT * FROM hmac_key),
CAST(jsonPayload.fields.target AS BYTES)
)
) AS target,
jsonPayload.fields.targetOS AS target_os,
jsonPayload.fields.targetType AS target_type,
TO_HEX(
udf.hmac_sha256((SELECT * FROM hmac_key), CAST(jsonPayload.fields.sender AS BYTES))
`moz-fx-data-shared-prod.udf.hmac_sha256`(
(SELECT * FROM hmac_key),
CAST(jsonPayload.fields.sender AS BYTES)
)
) AS sender,
jsonPayload.fields.senderOS AS sender_os,
jsonPayload.fields.senderType AS sender_type,

Просмотреть файл

@ -14,22 +14,31 @@ SELECT
`timestamp`,
jsonPayload.type,
TO_HEX(
udf.hmac_sha256((SELECT * FROM hmac_key), CAST(jsonPayload.fields.uid AS BYTES))
`moz-fx-data-shared-prod.udf.hmac_sha256`(
(SELECT * FROM hmac_key),
CAST(jsonPayload.fields.uid AS BYTES)
)
) AS user_id,
TO_HEX(
udf.hmac_sha256(
`moz-fx-data-shared-prod.udf.hmac_sha256`(
(SELECT * FROM hmac_key),
CAST(FORMAT('%d', CAST(jsonPayload.fields.index AS INT64)) AS BYTES)
)
) AS index,
jsonPayload.fields.command,
TO_HEX(
udf.hmac_sha256((SELECT * FROM hmac_key), CAST(jsonPayload.fields.target AS BYTES))
`moz-fx-data-shared-prod.udf.hmac_sha256`(
(SELECT * FROM hmac_key),
CAST(jsonPayload.fields.target AS BYTES)
)
) AS target,
jsonPayload.fields.targetOS AS target_os,
jsonPayload.fields.targetType AS target_type,
TO_HEX(
udf.hmac_sha256((SELECT * FROM hmac_key), CAST(jsonPayload.fields.sender AS BYTES))
`moz-fx-data-shared-prod.udf.hmac_sha256`(
(SELECT * FROM hmac_key),
CAST(jsonPayload.fields.sender AS BYTES)
)
) AS sender,
jsonPayload.fields.senderOS AS sender_os,
jsonPayload.fields.senderType AS sender_type,

Просмотреть файл

@ -38,18 +38,18 @@ WITH windowed AS (
DATE(`timestamp`) AS submission_date,
user_id,
ROW_NUMBER() OVER w1_unframed AS _n,
udf.mode_last(ARRAY_AGG(country) OVER w1) AS country,
udf.mode_last(ARRAY_AGG(`language`) OVER w1) AS language,
udf.mode_last(ARRAY_AGG(app_version) OVER w1) AS app_version,
udf.mode_last(ARRAY_AGG(os_name) OVER w1) AS os_name,
udf.mode_last(ARRAY_AGG(os_version) OVER w1) AS os_version,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(country) OVER w1) AS country,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(`language`) OVER w1) AS language,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(app_version) OVER w1) AS app_version,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(os_name) OVER w1) AS os_name,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(os_version) OVER w1) AS os_version,
udf_contains_tier1_country(ARRAY_AGG(country) OVER w1) AS seen_in_tier1_country,
udf_contains_registration(ARRAY_AGG(event_type) OVER w1) AS registered,
COUNTIF(
NOT (event_type = 'fxa_rp - engage' AND service = 'fx-monitor')
) OVER w1 = 0 AS monitor_only
FROM
firefox_accounts.fxa_all_events
`moz-fx-data-shared-prod.firefox_accounts.fxa_all_events`
WHERE
fxa_log IN ('auth', 'auth_bounce', 'content', 'oauth')
AND user_id IS NOT NULL

Просмотреть файл

@ -4,7 +4,7 @@
DATE(MIN(`timestamp`)) AS first_seen_date,
ARRAY_AGG(DISTINCT service IGNORE NULLS ORDER BY service) AS services_used,
FROM
firefox_accounts.fxa_all_events
`moz-fx-data-shared-prod.firefox_accounts.fxa_all_events`
WHERE
`timestamp` > '2010-01-01'
AND fxa_log IN ('auth', 'auth_bounce', 'content', 'oauth')
@ -16,7 +16,7 @@
user_id,
ARRAY_AGG(DISTINCT service IGNORE NULLS) AS services_used,
FROM
firefox_accounts.fxa_all_events
`moz-fx-data-shared-prod.firefox_accounts.fxa_all_events`
WHERE
DATE(`timestamp`) = @submission_date
AND fxa_log IN ('auth', 'auth_bounce', 'content', 'oauth')
@ -27,7 +27,7 @@
SELECT
*
FROM
firefox_accounts_derived.fxa_users_first_seen_v1
`moz-fx-data-shared-prod.firefox_accounts_derived.fxa_users_first_seen_v1`
WHERE
-- In reprocessing scenarios, we must always backfill from the first affected date
-- all the way to the present; to enforce that, we explicitly drop any data after

Просмотреть файл

@ -8,7 +8,7 @@ WITH _current AS (
seen_in_tier1_country,
registered,
FROM
firefox_accounts_derived.fxa_users_daily_v2
`moz-fx-data-shared-prod.firefox_accounts_derived.fxa_users_daily_v2`
WHERE
submission_date = @submission_date
),
@ -16,7 +16,7 @@ _previous AS (
SELECT
user_id
FROM
firefox_accounts_derived.fxa_users_first_seen_v2
`moz-fx-data-shared-prod.firefox_accounts_derived.fxa_users_first_seen_v2`
WHERE
-- In reprocessing scenarios, we must always backfill from the first affected date
-- all the way to the present; to enforce that, we explicitly drop any data after

Просмотреть файл

@ -35,24 +35,24 @@ _previous AS (
WHERE
submission_date = DATE_SUB(@submission_date, INTERVAL 1 DAY)
-- Filter out rows from yesterday that have now fallen outside the 28-day window.
AND udf.shift_28_bits_one_day(days_seen_bits) > 0
AND `moz-fx-data-shared-prod.udf.shift_28_bits_one_day`(days_seen_bits) > 0
)
SELECT
@submission_date AS submission_date,
IF(_current.user_id IS NOT NULL, _current, _previous).* REPLACE ( --
udf.combine_adjacent_days_28_bits(
`moz-fx-data-shared-prod.udf.combine_adjacent_days_28_bits`(
_previous.days_seen_bits,
_current.days_seen_bits
) AS days_seen_bits,
udf.combine_adjacent_days_28_bits(
`moz-fx-data-shared-prod.udf.combine_adjacent_days_28_bits`(
_previous.days_seen_in_tier1_country_bits,
_current.days_seen_in_tier1_country_bits
) AS days_seen_in_tier1_country_bits,
udf.coalesce_adjacent_days_28_bits(
`moz-fx-data-shared-prod.udf.coalesce_adjacent_days_28_bits`(
_previous.days_registered_bits,
_current.days_registered_bits
) AS days_registered_bits,
udf.combine_adjacent_days_28_bits(
`moz-fx-data-shared-prod.udf.combine_adjacent_days_28_bits`(
_previous.days_seen_no_monitor_bits,
_current.days_seen_no_monitor_bits
) AS days_seen_no_monitor_bits

Просмотреть файл

@ -12,7 +12,7 @@ WITH _current AS (
CAST(seen_in_tier1_country AS INT64) AS days_seen_in_tier1_country_bits,
CAST(registered AS INT64) AS days_registered_bits,
FROM
firefox_accounts_derived.fxa_users_daily_v2
`moz-fx-data-shared-prod.firefox_accounts_derived.fxa_users_daily_v2`
WHERE
submission_date = @submission_date
),
@ -23,24 +23,24 @@ _previous AS (
days_seen_in_tier1_country_bits,
days_registered_bits,
FROM
firefox_accounts_derived.fxa_users_last_seen_v2
`moz-fx-data-shared-prod.firefox_accounts_derived.fxa_users_last_seen_v2`
WHERE
submission_date = DATE_SUB(@submission_date, INTERVAL 1 DAY)
-- Filter out rows from yesterday that have now fallen outside the 28-day window.
AND udf.shift_28_bits_one_day(days_seen_bits) > 0
AND `moz-fx-data-shared-prod.udf.shift_28_bits_one_day`(days_seen_bits) > 0
)
SELECT
@submission_date AS submission_date,
IF(_current.user_id IS NOT NULL, _current, _previous).* REPLACE ( --
udf.combine_adjacent_days_28_bits(
`moz-fx-data-shared-prod.udf.combine_adjacent_days_28_bits`(
_previous.days_seen_bits,
_current.days_seen_bits
) AS days_seen_bits,
udf.combine_adjacent_days_28_bits(
`moz-fx-data-shared-prod.udf.combine_adjacent_days_28_bits`(
_previous.days_seen_in_tier1_country_bits,
_current.days_seen_in_tier1_country_bits
) AS days_seen_in_tier1_country_bits,
udf.coalesce_adjacent_days_28_bits(
`moz-fx-data-shared-prod.udf.coalesce_adjacent_days_28_bits`(
_previous.days_registered_bits,
_current.days_registered_bits
) AS days_registered_bits

Просмотреть файл

@ -70,11 +70,11 @@ windowed AS (
user_id,
service,
ROW_NUMBER() OVER w1_unframed AS _n,
udf.mode_last(ARRAY_AGG(country) OVER w1) AS country,
udf.mode_last(ARRAY_AGG(LANGUAGE) OVER w1) AS language,
udf.mode_last(ARRAY_AGG(app_version) OVER w1) AS app_version,
udf.mode_last(ARRAY_AGG(os_name) OVER w1) AS os_name,
udf.mode_last(ARRAY_AGG(os_version) OVER w1) AS os_version,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(country) OVER w1) AS country,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(LANGUAGE) OVER w1) AS language,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(app_version) OVER w1) AS app_version,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(os_name) OVER w1) AS os_name,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(os_version) OVER w1) AS os_version,
udf_contains_tier1_country(ARRAY_AGG(country) OVER w1) AS seen_in_tier1_country,
udf_contains_registration(ARRAY_AGG(event_type) OVER w1) AS registered
FROM

Просмотреть файл

@ -38,7 +38,7 @@ WITH fxa_events AS (
utm_campaign,
utm_content,
FROM
`firefox_accounts.fxa_all_events`
`moz-fx-data-shared-prod.firefox_accounts.fxa_all_events`
WHERE
-- 2 day time window used to make sure we can get user session attribution information
-- which will not always be available in the same partition as active user activity
@ -136,13 +136,13 @@ windowed AS (
`timestamp`,
user_id,
service,
udf.mode_last(ARRAY_AGG(country) OVER w1) AS country,
udf.mode_last(ARRAY_AGG(`language`) OVER w1) AS `language`,
udf.mode_last(ARRAY_AGG(app_version) OVER w1) AS app_version,
udf.mode_last(ARRAY_AGG(os_name) OVER w1) AS os_name,
udf.mode_last(ARRAY_AGG(os_version) OVER w1) AS os_version,
udf.mode_last(ARRAY_AGG(ua_version) OVER w1) AS ua_version,
udf.mode_last(ARRAY_AGG(ua_browser) OVER w1) AS ua_browser,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(country) OVER w1) AS country,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(`language`) OVER w1) AS `language`,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(app_version) OVER w1) AS app_version,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(os_name) OVER w1) AS os_name,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(os_version) OVER w1) AS os_version,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(ua_version) OVER w1) AS ua_version,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(ua_browser) OVER w1) AS ua_browser,
udf_contains_tier1_country(ARRAY_AGG(country) OVER w1) AS seen_in_tier1_country,
LOGICAL_OR(event_type = 'fxa_reg - complete') OVER w1 AS registered,
ARRAY_AGG(event_type) OVER w1 AS service_events,

Просмотреть файл

@ -18,7 +18,7 @@ WITH fxa_events AS (
ua_version,
ua_browser,
FROM
`firefox_accounts.fxa_all_events`
`moz-fx-data-shared-prod.firefox_accounts.fxa_all_events`
WHERE
DATE(`timestamp`)
-- 2 day time window used to make sure we can get user session attribution information

Просмотреть файл

@ -18,7 +18,7 @@ WITH new_device_entries AS (
ua_version,
ua_browser,
FROM
firefox_accounts_derived.fxa_users_services_devices_daily_v1
`moz-fx-data-shared-prod.firefox_accounts_derived.fxa_users_services_devices_daily_v1`
WHERE
DATE(`timestamp`) = @submission_date
),
@ -26,7 +26,7 @@ existing_devices AS (
SELECT DISTINCT
CONCAT(user_id, service, device_id) AS existing_entry
FROM
firefox_accounts_derived.fxa_users_services_devices_first_seen_v1
`moz-fx-data-shared-prod.firefox_accounts_derived.fxa_users_services_devices_first_seen_v1`
-- in case we backfill we want to exclude entries newer than submission_date
-- so that we can recalculate those partitions
WHERE

Просмотреть файл

@ -22,7 +22,7 @@ WITH _current AS (
-- rightmost bit represents whether the user was active in the current day.
CAST(TRUE AS INT64) AS days_seen_bits,
FROM
firefox_accounts_derived.fxa_users_services_devices_daily_v1
`moz-fx-data-shared-prod.firefox_accounts_derived.fxa_users_services_devices_daily_v1`
WHERE
DATE(`timestamp`) = @submission_date
AND event_type IN (
@ -35,16 +35,16 @@ _previous AS (
SELECT
* EXCEPT (submission_date)
FROM
firefox_accounts_derived.fxa_users_services_devices_last_seen_v1
`moz-fx-data-shared-prod.firefox_accounts_derived.fxa_users_services_devices_last_seen_v1`
WHERE
DATE(submission_date) = DATE_SUB(@submission_date, INTERVAL 1 DAY)
-- Filter out rows from yesterday that have now fallen outside the 28-day window.
AND udf.shift_28_bits_one_day(days_seen_bits) > 0
AND `moz-fx-data-shared-prod.udf.shift_28_bits_one_day`(days_seen_bits) > 0
),
combined AS (
SELECT
IF(_current.user_id IS NOT NULL, _current, _previous).* REPLACE (
udf.combine_adjacent_days_28_bits(
`moz-fx-data-shared-prod.udf.combine_adjacent_days_28_bits`(
_previous.days_seen_bits,
_current.days_seen_bits
) AS days_seen_bits

Просмотреть файл

@ -25,8 +25,12 @@
user_id,
service,
-- using mode_last with w1_reversed to get mode_first
udf.mode_last(ARRAY_AGG(`timestamp`) OVER w1_reversed) AS first_service_timestamp_last,
udf.mode_last(ARRAY_AGG(flow_id) OVER w1_reversed) AS first_service_flow,
`moz-fx-data-shared-prod.udf.mode_last`(
ARRAY_AGG(`timestamp`) OVER w1_reversed
) AS first_service_timestamp_last,
`moz-fx-data-shared-prod.udf.mode_last`(
ARRAY_AGG(flow_id) OVER w1_reversed
) AS first_service_flow,
LOGICAL_OR(IFNULL(event_type = 'fxa_reg - complete', FALSE)) OVER w1_reversed AS did_register
FROM
fxa_content_auth_oauth
@ -38,7 +42,7 @@
AND DATE(`timestamp`) >= '2019-03-01'
AND user_id IS NOT NULL
WINDOW
-- We must provide a window with `ORDER BY timestamp DESC` so that udf.mode_last actually aggregates mode first.
-- We must provide a window with `ORDER BY timestamp DESC` so that `moz-fx-data-shared-prod.udf.mode_last` actually aggregates mode first.
w1_reversed AS (
PARTITION BY
user_id,
@ -172,8 +176,12 @@
user_id,
service,
-- using mode_last with w1_reversed to get mode_first
udf.mode_last(ARRAY_AGG(`timestamp`) OVER w1_reversed) AS first_service_timestamp_last,
udf.mode_last(ARRAY_AGG(flow_id) OVER w1_reversed) AS first_service_flow,
`moz-fx-data-shared-prod.udf.mode_last`(
ARRAY_AGG(`timestamp`) OVER w1_reversed
) AS first_service_timestamp_last,
`moz-fx-data-shared-prod.udf.mode_last`(
ARRAY_AGG(flow_id) OVER w1_reversed
) AS first_service_flow,
LOGICAL_OR(IFNULL(event_type = 'fxa_reg - complete', FALSE)) OVER w1_reversed AS did_register
FROM
fxa_content_auth_oauth
@ -185,7 +193,7 @@
AND DATE(`timestamp`) >= '2019-03-01'
AND user_id IS NOT NULL
WINDOW
-- We must provide a window with `ORDER BY timestamp DESC` so that udf.mode_last actually aggregates mode first.
-- We must provide a window with `ORDER BY timestamp DESC` so that `moz-fx-data-shared-prod.udf.mode_last` actually aggregates mode first.
w1_reversed AS (
PARTITION BY
user_id,

Просмотреть файл

@ -13,7 +13,7 @@ WITH fxa_users_services_daily_new_entries AS (
user_service_utm_info,
registered,
FROM
firefox_accounts_derived.fxa_users_services_daily_v2
`moz-fx-data-shared-prod.firefox_accounts_derived.fxa_users_services_daily_v2`
WHERE
submission_date = @submission_date
),
@ -22,7 +22,7 @@ existing_entries AS (
user_id,
service,
FROM
firefox_accounts_derived.fxa_users_services_first_seen_v2
`moz-fx-data-shared-prod.firefox_accounts_derived.fxa_users_services_first_seen_v2`
WHERE
DATE(submission_date) < @submission_date
)

Просмотреть файл

@ -12,7 +12,7 @@ WITH _current AS (
CAST(registered AS INT64) AS days_registered_bits,
* EXCEPT (submission_date, seen_in_tier1_country, registered)
FROM
fxa_users_services_daily_v1
`moz-fx-data-shared-prod.firefox_accounts_derived.fxa_users_services_daily_v1`
WHERE
submission_date = @submission_date
),
@ -21,26 +21,26 @@ _previous AS (
SELECT
* EXCEPT (submission_date, resurrected_same_service, resurrected_any_service)
FROM
fxa_users_services_last_seen_v1
`moz-fx-data-shared-prod.firefox_accounts_derived.fxa_users_services_last_seen_v1`
WHERE
submission_date = DATE_SUB(@submission_date, INTERVAL 1 DAY)
-- Filter out rows from yesterday that have now fallen outside the 28-day window.
AND udf.shift_28_bits_one_day(days_seen_bits) > 0
AND `moz-fx-data-shared-prod.udf.shift_28_bits_one_day`(days_seen_bits) > 0
),
--
combined AS (
SELECT
@submission_date AS submission_date,
IF(_current.user_id IS NOT NULL, _current, _previous).* REPLACE ( --
udf.combine_adjacent_days_28_bits(
`moz-fx-data-shared-prod.udf.combine_adjacent_days_28_bits`(
_previous.days_seen_bits,
_current.days_seen_bits
) AS days_seen_bits,
udf.combine_adjacent_days_28_bits(
`moz-fx-data-shared-prod.udf.combine_adjacent_days_28_bits`(
_previous.days_seen_in_tier1_country_bits,
_current.days_seen_in_tier1_country_bits
) AS days_seen_in_tier1_country_bits,
udf.coalesce_adjacent_days_28_bits(
`moz-fx-data-shared-prod.udf.coalesce_adjacent_days_28_bits`(
_previous.days_registered_bits,
_current.days_registered_bits
) AS days_registered_bits
@ -58,7 +58,7 @@ previously_seen AS (
user_id,
service
FROM
fxa_users_services_first_seen_v1
`moz-fx-data-shared-prod.firefox_accounts_derived.fxa_users_services_first_seen_v1`
WHERE
DATE(first_service_timestamp) < @submission_date
),

Просмотреть файл

@ -46,7 +46,7 @@ WITH _current AS (
CAST(seen_in_tier1_country AS INT64) AS days_seen_in_tier1_country_bits,
CAST(registered AS INT64) AS days_registered_bits,
FROM
firefox_accounts_derived.fxa_users_services_daily_v2
`moz-fx-data-shared-prod.firefox_accounts_derived.fxa_users_services_daily_v2`
WHERE
submission_date = @submission_date
AND contains_qualified_fxa_activity_event(service_events)
@ -55,24 +55,24 @@ _previous AS (
SELECT
* EXCEPT (submission_date)
FROM
firefox_accounts_derived.fxa_users_services_last_seen_v2
`moz-fx-data-shared-prod.firefox_accounts_derived.fxa_users_services_last_seen_v2`
WHERE
submission_date = DATE_SUB(@submission_date, INTERVAL 1 DAY)
-- Filter out rows from yesterday that have now fallen outside the 28-day window.
AND udf.shift_28_bits_one_day(days_seen_bits) > 0
AND `moz-fx-data-shared-prod.udf.shift_28_bits_one_day`(days_seen_bits) > 0
)
SELECT
@submission_date AS submission_date,
IF(_current.user_id IS NOT NULL, _current, _previous).* REPLACE (
udf.combine_adjacent_days_28_bits(
`moz-fx-data-shared-prod.udf.combine_adjacent_days_28_bits`(
_previous.days_seen_bits,
_current.days_seen_bits
) AS days_seen_bits,
udf.combine_adjacent_days_28_bits(
`moz-fx-data-shared-prod.udf.combine_adjacent_days_28_bits`(
_previous.days_seen_in_tier1_country_bits,
_current.days_seen_in_tier1_country_bits
) AS days_seen_in_tier1_country_bits,
udf.coalesce_adjacent_days_28_bits(
`moz-fx-data-shared-prod.udf.coalesce_adjacent_days_28_bits`(
_previous.days_registered_bits,
_current.days_registered_bits
) AS days_registered_bits

Просмотреть файл

@ -5,7 +5,7 @@ WITH views_data AS (
territory AS country_name,
SUM(impressions_unique_device) AS views,
FROM
app_store.firefox_app_store_territory_source_type_report
`moz-fx-data-shared-prod.app_store.firefox_app_store_territory_source_type_report`
WHERE
DATE(`date`) = DATE_SUB(@submission_date, INTERVAL 7 DAY)
GROUP BY
@ -20,7 +20,7 @@ downloads_data AS (
SUM(first_time_downloads) AS first_time_downloads,
SUM(redownloads) AS redownloads,
FROM
app_store.firefox_downloads_territory_source_type_report
`moz-fx-data-shared-prod.app_store.firefox_downloads_territory_source_type_report`
WHERE
DATE(`date`) = DATE_SUB(@submission_date, INTERVAL 7 DAY)
AND source_type <> 'Institutional Purchase'
@ -42,7 +42,7 @@ store_stats AS (
downloads_data
USING (`date`, country_name)
LEFT JOIN
static.country_names_v1 AS country_names
`moz-fx-data-shared-prod.static.country_names_v1` AS country_names
ON country_names.name = views_data.country_name
),
_new_profiles AS (
@ -51,7 +51,7 @@ _new_profiles AS (
first_reported_country AS country,
COUNT(*) AS new_profiles,
FROM
firefox_ios.firefox_ios_clients
`moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients`
WHERE
first_seen_date = DATE_SUB(@submission_date, INTERVAL 7 DAY)
AND channel = "release"

Просмотреть файл

@ -15,7 +15,7 @@ WITH client_days AS (
SUM(sum_map_values(metrics.labeled_counter.browser_search_with_ads)) AS searches_with_ads,
SUM(sum_map_values(metrics.labeled_counter.browser_search_ad_clicks)) AS ad_clicks,
FROM
firefox_ios.baseline
`moz-fx-data-shared-prod.firefox_ios.baseline`
WHERE
{% if is_init() %}
DATE(submission_timestamp) >= "2020-05-01"
@ -37,7 +37,7 @@ metrics_searches AS (
SUM(search_with_ads) AS searches_with_ads,
SUM(ad_click) AS ad_clicks
FROM
search_derived.mobile_search_clients_daily_v1
`moz-fx-data-shared-prod.search_derived.mobile_search_clients_daily_v1`
WHERE
{% if is_init() %}
submission_date >= "2020-05-01"
@ -62,7 +62,7 @@ adjust_client_info AS (
adjust_creative,
metadata.is_reported_first_session_ping,
FROM
firefox_ios.firefox_ios_clients
`moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients`
)
SELECT
submission_date,

Просмотреть файл

@ -31,7 +31,9 @@
-- 365 days for each usage criterion as an array of bytes. The
-- rightmost bit represents whether the user was active in the current day.
{% for usage_type, criterion in usage_types %}
udf.bool_to_365_bits({{ criterion }}) AS `days_{{ usage_type }}_bytes`,
`moz-fx-data-shared-prod.udf.bool_to_365_bits`(
{{ criterion }}
) AS `days_{{ usage_type }}_bytes`,
{% endfor %}
-- List cols explicitly here: the schema is static (schema.yaml),
-- and new columns added upstream will need to be manually added
@ -76,7 +78,7 @@
WHERE
submission_date = DATE_SUB(@submission_date, INTERVAL 1 DAY)
-- Filter out rows from yesterday that have now fallen outside the 365-day window.
AND BIT_COUNT(udf.shift_365_bits_one_day(days_seen_bytes)) > 0
AND BIT_COUNT(`moz-fx-data-shared-prod.udf.shift_365_bits_one_day`(days_seen_bytes)) > 0
AND sample_id IS NOT NULL
)
--
@ -84,7 +86,7 @@
@submission_date AS submission_date,
IF(_current.client_id IS NOT NULL, _current, _previous).* REPLACE (
{% for usage_type, _ in usage_types %}
udf.combine_adjacent_days_365_bits(
`moz-fx-data-shared-prod.udf.combine_adjacent_days_365_bits`(
_previous.`days_{{ usage_type }}_bytes`,
_current.`days_{{ usage_type }}_bytes`
) AS `days_{{ usage_type }}_bytes` {{ "," if not loop.last }}

Просмотреть файл

@ -12,7 +12,7 @@ WITH new_clients AS (
sample_id,
channel,
FROM
firefox_ios.firefox_ios_clients
`moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients`
WHERE
first_seen_date = DATE_SUB(@submission_date, INTERVAL 6 DAY)
),
@ -26,7 +26,7 @@ new_clients_activity AS (
mozfun.bits28.to_dates(mozfun.bits28.range(days_seen_bits, -5, 6), submission_date)
) AS days_2_7,
FROM
firefox_ios.baseline_clients_last_seen
`moz-fx-data-shared-prod.firefox_ios.baseline_clients_last_seen`
WHERE
submission_date = @submission_date
AND DATE_DIFF(submission_date, first_seen_date, DAY) = 6
@ -38,7 +38,7 @@ clients_search AS (
channel,
SUM(search_count) AS search_count
FROM
search_derived.mobile_search_clients_daily_v1
`moz-fx-data-shared-prod.search_derived.mobile_search_clients_daily_v1`
WHERE
(submission_date BETWEEN DATE_SUB(@submission_date, INTERVAL 3 DAY) AND @submission_date)
AND os = 'iOS'

Просмотреть файл

@ -7,7 +7,7 @@ WITH baseline_clients AS (
normalized_channel AS channel,
normalized_country_code AS country
FROM
firefox_ios.baseline
`moz-fx-data-shared-prod.firefox_ios.baseline`
WHERE
metrics.timespan.glean_baseline_duration.value > 0
AND LOWER(metadata.isp.name) <> "browserstack"
@ -31,7 +31,7 @@ client_attribution AS (
channel,
adjust_network,
FROM
firefox_ios.firefox_ios_clients
`moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients`
),
default_browser AS (
SELECT
@ -45,7 +45,7 @@ default_browser AS (
normalized_country_code AS country,
IF(SUM(metrics.counter.app_opened_as_default_browser) > 0, TRUE, FALSE) AS is_default_browser
FROM
firefox_ios.metrics AS metric_ping
`moz-fx-data-shared-prod.firefox_ios.metrics` AS metric_ping
WHERE
LOWER(metadata.isp.name) <> "browserstack"
-- we need to work with a larger time window as some metrics ping arrive with a multi day delay
@ -272,7 +272,7 @@ event_ping_clients_feature_usage AS (
AND event_name = 'settings_autofill'
) AS address_settings_autofill
FROM
firefox_ios.events_unnested
`moz-fx-data-shared-prod.firefox_ios.events_unnested`
LEFT JOIN
UNNEST(event_extra) AS extra
WHERE

Просмотреть файл

@ -7,7 +7,7 @@ WITH baseline_clients AS (
normalized_channel AS channel,
normalized_country_code AS country
FROM
firefox_ios.baseline
`moz-fx-data-shared-prod.firefox_ios.baseline`
WHERE
metrics.timespan.glean_baseline_duration.value > 0
AND LOWER(metadata.isp.name) <> "browserstack"
@ -31,7 +31,7 @@ client_attribution AS (
channel,
adjust_network,
FROM
firefox_ios.firefox_ios_clients
`moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients`
),
metric_ping_clients_feature_usage AS (
SELECT
@ -102,7 +102,7 @@ metric_ping_clients_feature_usage AS (
--Address
SUM(COALESCE(metrics.quantity.addresses_saved_all, 0)) AS addresses_saved_all
FROM
firefox_ios.metrics AS metric_ping
`moz-fx-data-shared-prod.firefox_ios.metrics` AS metric_ping
LEFT JOIN
UNNEST(metrics.labeled_counter.bookmarks_add) AS bookmarks_add_table
LEFT JOIN

Просмотреть файл

@ -13,7 +13,7 @@
normalized_os_version AS os_version,
app_display_version AS app_version
FROM
firefox_ios.baseline_clients_first_seen
`moz-fx-data-shared-prod.firefox_ios.baseline_clients_first_seen`
WHERE
submission_date < CURRENT_DATE
AND client_id IS NOT NULL
@ -29,7 +29,7 @@
NULLIF(metrics.string.adjust_creative, "") AS adjust_creative,
NULLIF(metrics.string.adjust_network, "") AS adjust_network,
FROM
firefox_ios.first_session
`moz-fx-data-shared-prod.firefox_ios.first_session`
WHERE
DATE(submission_timestamp) < CURRENT_DATE
AND client_info.client_id IS NOT NULL
@ -75,7 +75,7 @@
NULLIF(fxa_metrics.metrics.string.adjust_creative, "") AS adjust_creative,
NULLIF(fxa_metrics.metrics.string.adjust_network, "") AS adjust_network,
FROM
firefox_ios.metrics AS fxa_metrics
`moz-fx-data-shared-prod.firefox_ios.metrics` AS fxa_metrics
WHERE
DATE(submission_timestamp) < CURRENT_DATE
AND client_info.client_id IS NOT NULL
@ -171,7 +171,7 @@
normalized_os_version AS os_version,
app_display_version AS app_version,
FROM
firefox_ios.baseline_clients_first_seen
`moz-fx-data-shared-prod.firefox_ios.baseline_clients_first_seen`
WHERE
submission_date = @submission_date
AND client_id IS NOT NULL
@ -187,7 +187,7 @@
NULLIF(metrics.string.adjust_creative, "") AS adjust_creative,
NULLIF(metrics.string.adjust_network, "") AS adjust_network,
FROM
firefox_ios.first_session
`moz-fx-data-shared-prod.firefox_ios.first_session`
WHERE
DATE(submission_timestamp) = @submission_date
AND client_info.client_id IS NOT NULL
@ -233,7 +233,7 @@
NULLIF(fxa_metrics.metrics.string.adjust_creative, "") AS adjust_creative,
NULLIF(fxa_metrics.metrics.string.adjust_network, "") AS adjust_network,
FROM
firefox_ios.metrics AS fxa_metrics
`moz-fx-data-shared-prod.firefox_ios.metrics` AS fxa_metrics
WHERE
DATE(submission_timestamp) = @submission_date
AND client_info.client_id IS NOT NULL
@ -309,7 +309,7 @@
SELECT
*
FROM
firefox_ios_derived.firefox_ios_clients_v1
`moz-fx-data-shared-prod.firefox_ios_derived.firefox_ios_clients_v1`
)
SELECT
client_id,

Просмотреть файл

@ -5,7 +5,7 @@ WITH clients_retention AS (
sample_id,
days_seen_bits,
FROM
firefox_ios.baseline_clients_last_seen
`moz-fx-data-shared-prod.firefox_ios.baseline_clients_last_seen`
WHERE
submission_date = @submission_date
AND normalized_channel = "release"
@ -22,7 +22,7 @@ clients_first_seen AS (
adjust_creative,
adjust_network,
FROM
firefox_ios.firefox_ios_clients
`moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients`
WHERE
-- Two weeks need to elapse before calculating the week 2 retention
first_seen_date = DATE_SUB(@submission_date, INTERVAL 13 DAY)

Просмотреть файл

@ -5,7 +5,7 @@ WITH clients_retention AS (
sample_id,
days_seen_bits,
FROM
firefox_ios.baseline_clients_last_seen
`moz-fx-data-shared-prod.firefox_ios.baseline_clients_last_seen`
WHERE
submission_date = @submission_date
AND normalized_channel = "release"
@ -22,7 +22,7 @@ clients_first_seen AS (
adjust_creative,
adjust_network,
FROM
firefox_ios.firefox_ios_clients
`moz-fx-data-shared-prod.firefox_ios.firefox_ios_clients`
WHERE
-- 28 days need to elapse before calculating the week 4 and day 28 retention metrics
first_seen_date = DATE_SUB(@submission_date, INTERVAL 27 DAY)

Просмотреть файл

@ -11,7 +11,7 @@ SELECT
COUNTIF(repeat_first_month_user) AS repeat_user,
COUNTIF(retained_week_4) AS retained_week_4,
FROM
firefox_ios_derived.funnel_retention_clients_week_4_v1
`moz-fx-data-shared-prod.firefox_ios_derived.funnel_retention_clients_week_4_v1`
WHERE
submission_date = @submission_date
GROUP BY

Просмотреть файл

@ -14,7 +14,7 @@ WITH dou AS (
mozfun.bits28.to_dates(mozfun.bits28.range(days_seen_bits, -5, 6), submission_date)
) AS days_2_7,
FROM
firefox_ios.baseline_clients_last_seen
`moz-fx-data-shared-prod.firefox_ios.baseline_clients_last_seen`
WHERE
submission_date = @submission_date
AND DATE_DIFF(submission_date, first_seen_date, DAY) = 6
@ -24,7 +24,7 @@ client_search AS (
client_id,
SUM(search_count) AS search_count
FROM
search_derived.mobile_search_clients_daily_v1
`moz-fx-data-shared-prod.search_derived.mobile_search_clients_daily_v1`
WHERE
(submission_date BETWEEN DATE_SUB(@submission_date, INTERVAL 3 DAY) AND @submission_date)
AND os = 'iOS'
@ -42,7 +42,7 @@ previous_client_entries AS (
SELECT
client_id
FROM
firefox_ios_derived.new_profile_activation_v2
`moz-fx-data-shared-prod.firefox_ios_derived.new_profile_activation_v2`
WHERE
`date` < @submission_date
)

Просмотреть файл

@ -26,5 +26,5 @@ SELECT
FROM
ad_group_names
JOIN
google_ads_derived.campaigns_v1 AS campaigns
`moz-fx-data-shared-prod.google_ads_derived.campaigns_v1` AS campaigns
ON campaigns.campaign_id = ad_group_names.campaign_id

Просмотреть файл

@ -23,5 +23,5 @@ SELECT
FROM
conversion_counts
JOIN
google_ads_derived.campaign_names_map_v1
`moz-fx-data-shared-prod.google_ads_derived.campaign_names_map_v1`
USING (campaign_id, account_id)

Просмотреть файл

@ -16,7 +16,7 @@ SELECT
FROM
campaign_names
JOIN
google_ads_derived.accounts_v1 AS accounts
`moz-fx-data-shared-prod.google_ads_derived.accounts_v1` AS accounts
ON accounts.account_id = campaign_names.customer_id
WHERE
campaign_names.is_most_recent_record

Просмотреть файл

@ -27,5 +27,5 @@ SELECT
FROM
campaign_names
JOIN
google_ads_derived.accounts_v1 AS accounts
`moz-fx-data-shared-prod.google_ads_derived.accounts_v1` AS accounts
ON accounts.account_id = campaign_names.customer_id

Просмотреть файл

@ -18,5 +18,5 @@ SELECT
FROM
campaign_names
JOIN
google_ads_derived.accounts_v1 AS accounts
`moz-fx-data-shared-prod.google_ads_derived.accounts_v1` AS accounts
ON accounts.account_id = campaign_names.customer_id

Просмотреть файл

@ -1,4 +1,4 @@
-- Note: udf.udf_json_extract_int_map map doesn't work in this case as it expects an INT -> INT
-- Note: `moz-fx-data-shared-prod.udf.udf_json_extract_int_map` map doesn't work in this case as it expects an INT -> INT
-- map, while we have a STRING->int map
CREATE TEMP FUNCTION udf_json_extract_string_to_int_map(input STRING) AS (
ARRAY(
@ -84,7 +84,7 @@ WITH DAUs AS (
TIMESTAMP_TRUNC(submission_timestamp_min, HOUR) AS datetime,
COUNT(*) AS client_count
FROM
telemetry.clients_daily
`moz-fx-data-shared-prod.telemetry.clients_daily`
WHERE
submission_date = @submission_date
-- Country can be null if geoip lookup failed.
@ -107,10 +107,12 @@ WITH DAUs AS (
health_data_sample AS (
SELECT
-- `city` is processed in `health_data_aggregates`.
udf.geo_struct(metadata.geo.country, metadata.geo.city, NULL, NULL).* EXCEPT (
geo_subdivision1,
geo_subdivision2
),
`moz-fx-data-shared-prod.udf.geo_struct`(
metadata.geo.country,
metadata.geo.city,
NULL,
NULL
).* EXCEPT (geo_subdivision1, geo_subdivision2),
TIMESTAMP_TRUNC(submission_timestamp, HOUR) AS datetime,
client_id,
SUM(
@ -156,7 +158,7 @@ health_data_sample AS (
)
) AS e_channel_open,
FROM
telemetry.health
`moz-fx-data-shared-prod.telemetry.health`
WHERE
DATE(submission_timestamp) = @submission_date
GROUP BY
@ -211,7 +213,7 @@ final_health_data AS (
-- Compute aggregates for histograms coming from the health ping.
histogram_data_sample AS (
SELECT
-- We don't need to use udf.geo_struct here since `telemetry.main` won't
-- We don't need to use `moz-fx-data-shared-prod.udf.geo_struct` here since `telemetry.main` won't
-- have '??' values. It only has nulls, which we can handle.
metadata.geo.country AS country,
-- If cities are NULL then it's from cities we either don't
@ -228,7 +230,7 @@ histogram_data_sample AS (
payload.processes.content.histograms.http_page_tls_handshake
).values AS tls_handshake,
FROM
telemetry_stable.main_v5
`moz-fx-data-shared-prod.telemetry_stable.main_v5`
WHERE
DATE(submission_timestamp) = @submission_date
-- Restrict to Firefox.
@ -485,7 +487,7 @@ FROM
-- with whatever we pass on the RIGHT.
-- When doing a FULL OUTER JOIN, we end up sometimes with nulls on the
-- left because there are a few samples coming from telemetry.main that
-- are not accounted for in telemetry.clients_daily
-- are not accounted for in `moz-fx-data-shared-prod.telemetry.clients_daily`
LEFT JOIN
DAUs
USING (datetime, country, city)

Просмотреть файл

@ -12,9 +12,9 @@ SELECT
COUNTIF(days_since_seen_whats_new < 7) AS whats_new_wau,
COUNTIF(days_since_seen_whats_new < 1) AS whats_new_dau
FROM
messaging_system.cfr_users_last_seen AS culs
`moz-fx-data-shared-prod.messaging_system.cfr_users_last_seen` AS culs
LEFT JOIN
static.country_codes_v1 AS cc
`moz-fx-data-shared-prod.static.country_codes_v1` AS cc
ON (culs.country = cc.code)
WHERE
(client_id IS NOT NULL OR impression_id IS NOT NULL)

Просмотреть файл

@ -9,12 +9,12 @@ WITH windowed AS (
(COUNTIF(bucket_id LIKE r'%WHATS\_NEW%') OVER w1 > 0) AS seen_whats_new,
--
-- For all dimensions, we use the mode of observed values in the day.
udf.mode_last(ARRAY_AGG(release_channel) OVER w1) AS release_channel,
udf.mode_last(ARRAY_AGG(locale) OVER w1) AS locale,
udf.mode_last(ARRAY_AGG(metadata.geo.country) OVER w1) AS country,
udf.mode_last(ARRAY_AGG(version) OVER w1) AS version
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(release_channel) OVER w1) AS release_channel,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(locale) OVER w1) AS locale,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(metadata.geo.country) OVER w1) AS country,
`moz-fx-data-shared-prod.udf.mode_last`(ARRAY_AGG(version) OVER w1) AS version
FROM
messaging_system.cfr
`moz-fx-data-shared-prod.messaging_system.cfr`
WHERE
-- Reprocess all dates by running this query with --parameter=submission_date:DATE:NULL
(@submission_date IS NULL OR @submission_date = DATE(submission_timestamp))

Просмотреть файл

@ -12,7 +12,7 @@ WITH _current AS (
CAST(seen_whats_new AS INT64) AS days_seen_whats_new_bits,
* EXCEPT (submission_date)
FROM
cfr_users_daily_v1
`moz-fx-data-shared-prod.messaging_system_derived.cfr_users_daily_v1`
WHERE
submission_date = @submission_date
),
@ -22,20 +22,20 @@ _previous AS (
COALESCE(impression_id, client_id) AS _join_key,
* EXCEPT (submission_date)
FROM
cfr_users_last_seen_v1
`moz-fx-data-shared-prod.messaging_system_derived.cfr_users_last_seen_v1`
WHERE
submission_date = DATE_SUB(@submission_date, INTERVAL 1 DAY)
AND udf.shift_28_bits_one_day(days_seen_bits) > 0
AND `moz-fx-data-shared-prod.udf.shift_28_bits_one_day`(days_seen_bits) > 0
)
--
SELECT
@submission_date AS submission_date,
IF(_current._join_key IS NOT NULL, _current, _previous).* EXCEPT (_join_key) REPLACE(
udf.combine_adjacent_days_28_bits(
`moz-fx-data-shared-prod.udf.combine_adjacent_days_28_bits`(
_previous.days_seen_bits,
_current.days_seen_bits
) AS days_seen_bits,
udf.combine_adjacent_days_28_bits(
`moz-fx-data-shared-prod.udf.combine_adjacent_days_28_bits`(
_previous.days_seen_whats_new_bits,
_current.days_seen_whats_new_bits
) AS days_seen_whats_new_bits

Просмотреть файл

@ -9,9 +9,9 @@ SELECT
COUNTIF(days_since_seen < 7) AS wau,
COUNTIF(days_since_seen < 1) AS dau,
FROM
messaging_system.onboarding_users_last_seen AS ouls
`moz-fx-data-shared-prod.messaging_system.onboarding_users_last_seen` AS ouls
LEFT JOIN
static.country_codes_v1 AS cc
`moz-fx-data-shared-prod.static.country_codes_v1` AS cc
ON (ouls.country = cc.code)
WHERE
client_id IS NOT NULL

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше