Skip to content

Commit 4bf68ef

Browse files
committed
Removed init
1 parent d5de056 commit 4bf68ef

File tree

4 files changed

+1
-274
lines changed

4 files changed

+1
-274
lines changed

sql_generators/baseline_clients_city_seen_v1/templates/query.sql

Lines changed: 1 addition & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,15 @@ WITH
1616
metadata.geo.subdivision2 AS subdivision2,
1717
metadata.geo.country AS country
1818
FROM
19-
{% raw %}
20-
{% if is_init() %}
21-
{% endraw %}
22-
`{{ project_id }}.{{ app_id }}_stable.baseline_v1`
23-
{% raw %}
24-
{% else %}
25-
{% endraw %}
2619
`{{ project_id }}.{{ app_id }}_live.baseline_v1`
27-
{% raw %}
28-
{% endif %}
29-
{% endraw %}
3020
WHERE
3121
client_info.client_id IS NOT NULL
32-
{% raw %}
33-
{% if is_init() %}
34-
{% endraw %}
35-
AND sample_id = @sample_id
36-
AND DATE(submission_timestamp) <= CURRENT_DATE()
37-
{% raw %}
38-
{% else %}
39-
{% endraw %}
4022
AND DATE(submission_timestamp) = @submission_date
4123
AND 'automation' NOT IN (
4224
SELECT TRIM(t) FROM UNNEST(SPLIT(metadata.header.x_source_tags, ',')) t
4325
)
4426
QUALIFY
4527
ROW_NUMBER() OVER (PARTITION BY document_id ORDER BY submission_timestamp ) = 1
46-
{% raw %}
47-
{% endif %}
48-
{% endraw %}
4928
),
5029
overactive_{{ app_id }} AS (
5130
-- Find client_ids with over 150 000 pings in a day,
@@ -56,17 +35,7 @@ WITH
5635
FROM
5736
base_{{ app_id }}
5837
WHERE
59-
{% raw %}
60-
{% if is_init() %}
61-
{% endraw %}
62-
submission_date >= '2018-01-01'
63-
{% raw %}
64-
{% else %}
65-
{% endraw %}
6638
submission_date = @submission_date
67-
{% raw %}
68-
{% endif %}
69-
{% endraw %}
7039
GROUP BY
7140
submission_date,
7241
client_id
@@ -100,56 +69,10 @@ WITH
10069
-- `mode_last` can result in struct with all null values if it’s most frequent (or latest among ties).
10170
-- This exclude structs with all null values so there will always be one non-NULL field.
10271
AND COALESCE(city, subdivision1, subdivision2, country) IS NOT NULL
103-
{% raw %}
104-
{% if is_init() %}
105-
{% endraw %}
106-
AND submission_date >= '2018-01-01'
107-
{% raw %}
108-
{% else %}
109-
{% endraw %}
11072
AND submission_date = @submission_date
111-
{% raw %}
112-
{% endif %}
113-
{% endraw %}
11473
GROUP BY
11574
submission_date, client_id, sample_id
11675
),
117-
{% raw %}
118-
{% if is_init() %}
119-
{% endraw %}
120-
clients_city_first_seen_{{ app_id }} AS (
121-
SELECT
122-
app_id,
123-
client_id,
124-
sample_id,
125-
submission_date AS first_seen_city_date,
126-
geo.city AS first_seen_city,
127-
geo.subdivision1 AS first_seen_subdivision1,
128-
geo.subdivision2 AS first_seen_subdivision2,
129-
geo.country AS first_seen_country
130-
FROM
131-
clients_daily_{{ app_id }}
132-
WHERE geo.city IS NOT NULL
133-
QUALIFY
134-
ROW_NUMBER() OVER (PARTITION BY client_id, sample_id ORDER BY submission_date ) = 1),
135-
clients_city_last_seen_{{ app_id }} AS (
136-
SELECT
137-
app_id,
138-
client_id,
139-
sample_id,
140-
submission_date AS last_seen_city_date,
141-
geo.city AS last_seen_city,
142-
geo.subdivision1 AS last_seen_subdivision1,
143-
geo.subdivision2 AS last_seen_subdivision2,
144-
geo.country AS last_seen_country
145-
FROM
146-
clients_daily_{{ app_id }}
147-
WHERE geo.city IS NOT NULL
148-
QUALIFY
149-
ROW_NUMBER() OVER (PARTITION BY client_id, sample_id ORDER BY submission_date DESC) = 1 ){{ "," if not loop.last }}
150-
{% raw %}
151-
{% else %}
152-
{% endraw %}
15376
_previous_{{ app_id }} AS (
15477
SELECT
15578
*
@@ -176,38 +99,7 @@ WITH
17699
clients_daily_{{ app_id }}
177100
WHERE
178101
geo.city IS NOT NULL){{ "," if not loop.last }}
179-
{% raw %}
180-
{% endif %}
181-
{% endraw %}
182102
{% endfor -%}
183-
{% raw %}
184-
{% if is_init() %}
185-
{% endraw %}
186-
{% for app_id in app_id_list -%}
187-
SELECT
188-
app_id,
189-
client_id,
190-
sample_id,
191-
first_seen_city_date,
192-
first_seen_city,
193-
first_seen_subdivision1,
194-
first_seen_subdivision2,
195-
first_seen_country,
196-
last_seen_city_date,
197-
last_seen_city,
198-
last_seen_subdivision1,
199-
last_seen_subdivision2,
200-
last_seen_country
201-
FROM
202-
clients_city_first_seen_{{ app_id }} cfs
203-
FULL OUTER JOIN
204-
clients_city_last_seen_{{ app_id }} cls
205-
USING (client_id, sample_id, app_id)
206-
{{ "UNION ALL" if not loop.last }}
207-
{% endfor -%}
208-
{% raw %}
209-
{% else %}
210-
{% endraw %}
211103
{% for app_id in app_id_list -%}
212104
SELECT
213105
-- _p.* fields are NULL for clients that are not yet captured in the baseline_city_seen derived table.
@@ -284,6 +176,4 @@ USING
284176
(client_id, sample_id, app_id)
285177
{{ "UNION ALL" if not loop.last }}
286178
{% endfor -%}
287-
{% raw %}
288-
{% endif %}
289-
{% endraw %}
179+

tests/sql/moz-fx-data-shared-prod/firefox_desktop_derived/baseline_clients_city_seen_v1/test_init/expect.yaml

Lines changed: 0 additions & 43 deletions
This file was deleted.

tests/sql/moz-fx-data-shared-prod/firefox_desktop_derived/baseline_clients_city_seen_v1/test_init/moz-fx-data-shared-prod.firefox_desktop_stable.baseline_v1.yaml

Lines changed: 0 additions & 116 deletions
This file was deleted.

tests/sql/moz-fx-data-shared-prod/firefox_desktop_derived/baseline_clients_city_seen_v1/test_init/query_params.yaml

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)