Init statement & sample id addition (#1304)

* Include sample_id in events_daily

* Add init query for events_daily

* Add sample_id to init
This commit is contained in:
Frank Bertsch 2020-09-11 11:53:21 -04:00 коммит произвёл GitHub
Родитель a9f00f3b15
Коммит 722e6ece6e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 43 добавлений и 1 удалений

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

@ -0,0 +1,39 @@
CREATE TABLE
org_mozilla_firefox_derived.events_daily_v1
PARTITION BY
submission_date
CLUSTER BY
sample_id
OPTIONS
(require_partition_filter = TRUE)
AS
SELECT
CAST(NULL AS date) AS submission_date,
CAST(NULL AS STRING) AS client_id,
CAST(NULL AS INT64) AS sample_id,
CAST(NULL AS STRING) AS events,
-- client info
CAST(NULL AS STRING) AS android_sdk_version,
CAST(NULL AS STRING) AS app_build,
CAST(NULL AS STRING) AS app_channel,
CAST(NULL AS STRING) AS app_display_version,
CAST(NULL AS STRING) AS architecture,
CAST(NULL AS STRING) AS device_manufacturer,
CAST(NULL AS STRING) AS device_model,
CAST(NULL AS STRING) AS first_run_date,
CAST(NULL AS STRING) AS telemetry_sdk_build,
CAST(NULL AS STRING) AS locale,
-- metadata
CAST(NULL AS STRING) AS city,
CAST(NULL AS STRING) AS country,
CAST(NULL AS STRING) AS subdivision1,
-- normalized fields
CAST(NULL AS STRING) AS channel,
CAST(NULL AS STRING) AS os,
CAST(NULL AS STRING) AS os_version,
-- ping info
CAST(NULL AS ARRAY<STRUCT<key STRING, value STRING>>) AS experiments
FROM
org_mozilla_firefox.events
WHERE
FALSE

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

@ -6,6 +6,7 @@ WITH events AS (
name AS event,
extra AS event_properties,
client_info.* EXCEPT (os, os_version),
sample_id,
metadata.geo.city,
metadata.geo.country,
metadata.geo.subdivision1,
@ -42,6 +43,7 @@ joined AS (
SELECT
submission_date,
client_id,
sample_id,
CONCAT(STRING_AGG(index, ',' ORDER BY timestamp ASC), ',') AS events,
-- client info
mozfun.stats.mode_last(ARRAY_AGG(android_sdk_version)) AS android_sdk_version,
@ -68,4 +70,5 @@ FROM
joined
GROUP BY
submission_date,
client_id
client_id,
sample_id