File tree Expand file tree Collapse file tree 2 files changed +72
-0
lines changed
sql_generators/usage_reporting Expand file tree Collapse file tree 2 files changed +72
-0
lines changed Original file line number Diff line number Diff line change 3030)
3131APP_UNION_VIEW_TEMPLATE = "app_union.view.sql.jinja"
3232ACTIVE_USERS_VIEW_TEMPLATE = "usage_reporting_active_users.view.sql.jinja"
33+ COMPOSITE_ACTIVE_USERS_TEMPLATE = "composite_active_users.view.sql.jinja"
3334
3435
3536@click .command ()
@@ -220,3 +221,24 @@ def generate(
220221 sql = reformat (rendered_active_users_view ),
221222 skip_existing = False ,
222223 )
224+
225+ composite_active_users_dataset_name = COMPOSITE_ACTIVE_USERS_TEMPLATE .split (
226+ "."
227+ )[0 ]
228+ composite_active_users_view_template = jinja_env .get_template (
229+ COMPOSITE_ACTIVE_USERS_TEMPLATE
230+ )
231+ rendered_composite_active_users_view = (
232+ composite_active_users_view_template .render (
233+ ** app_template_args ,
234+ view_name = composite_active_users_dataset_name ,
235+ )
236+ )
237+
238+ write_sql (
239+ output_dir = output_dir ,
240+ full_table_id = f"{ target_project } .{ app_name } .{ composite_active_users_dataset_name } " ,
241+ basename = "view.sql" ,
242+ sql = reformat (rendered_composite_active_users_view ),
243+ skip_existing = False ,
244+ )
Original file line number Diff line number Diff line change 1+ CREATE OR REPLACE VIEW
2+ `{{ project_id }}.{{ app_name }}.{{ view_name }}`
3+ AS
4+ SELECT
5+ submission_date,
6+ first_seen_year,
7+ channel,
8+ app_name,
9+ app_version,
10+ country,
11+ os,
12+ os_version,
13+ distribution_id,
14+ is_default_browser,
15+ activity_segment,
16+ is_dau,
17+ is_wau,
18+ is_mau,
19+ is_daily_user,
20+ is_weekly_user,
21+ is_monthly_user,
22+ FROM
23+ {% if app_name == "firefox_desktop" %}
24+ `{{ project_id }}.{{ app_name }}.baseline_active_users`
25+ {% else %}
26+ `{{ project_id }}.{{ app_name }}.active_users`
27+ {% endif %}
28+ -- TODO: will need to add some sort of filter to reduce double counting.
29+ UNION ALL
30+ SELECT
31+ submission_date,
32+ first_seen_year,
33+ channel,
34+ app_name,
35+ app_version,
36+ country,
37+ os,
38+ os_version,
39+ distribution_id,
40+ is_default_browser,
41+ activity_segment,
42+ is_dau,
43+ is_wau,
44+ is_mau,
45+ is_daily_user,
46+ is_weekly_user,
47+ is_monthly_user,
48+ FROM
49+ `{{ project_id }}.{{ app_name }}.usage_reporting_active_users`
50+ -- TODO: will need to add some sort of filter to reduce double counting.
You can’t perform that action at this time.
0 commit comments