Skip to content

Commit b91dcdd

Browse files
committed
Initial commit
0 parents  commit b91dcdd

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
BigQuery ETL
2+
===
3+
4+
Bigquery UDFs and SQL queries for building derived datasets.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
SELECT
2+
@submission_date AS submission_date,
3+
CURRENT_DATETIME() AS generated_time,
4+
COUNT(DISTINCT client_id) AS mau,
5+
SUM(CAST(submission_date_s3 = @submission_date AS INT64)) as dau
6+
FROM
7+
clients_daily_v6
8+
WHERE
9+
submission_date_s3 <= @submission_date
10+
AND submission_date_s3 > DATE_ADD(@submission_date, INTERVAL -28 DAY)

udf/get_key.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CREATE TEMP FUNCTION get_key(map ANY TYPE, k ANY TYPE) AS (
2+
(
3+
SELECT key_value.value
4+
FROM UNNEST(map.key_value) AS key_value
5+
WHERE key_value.key = k
6+
LIMIT 1
7+
)
8+
);

0 commit comments

Comments
 (0)