Skip to content

Commit

Permalink
snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamDee committed Oct 23, 2024
1 parent 2601489 commit 98d16f5
Show file tree
Hide file tree
Showing 142 changed files with 20,138 additions and 13,539 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ SELECT
FROM (
-- Combine Aggregated Outputs
SELECT
COALESCE(subq_20.metric_time__day, subq_30.metric_time__day) AS metric_time__day
, MAX(subq_20.visits) AS visits
, MAX(subq_30.buys) AS buys
COALESCE(subq_21.metric_time__day, subq_32.metric_time__day) AS metric_time__day
, MAX(subq_21.visits) AS visits
, MAX(subq_32.buys) AS buys
FROM (
-- Constrain Output with WHERE
-- Aggregate Measures
Expand All @@ -22,11 +22,11 @@ FROM (
DATETIME_TRUNC(ds, day) AS metric_time__day
, 1 AS visits
FROM ***************************.fct_visits visits_source_src_28000
) subq_18
) subq_19
WHERE metric_time__day = '2020-01-01'
GROUP BY
metric_time__day
) subq_20
) subq_21
FULL OUTER JOIN (
-- Find conversions for user within the range of INF
-- Pass Only Elements: ['buys', 'metric_time__day']
Expand All @@ -37,51 +37,60 @@ FROM (
FROM (
-- Dedupe the fanout with mf_internal_uuid in the conversion data set
SELECT DISTINCT
FIRST_VALUE(subq_23.visits) OVER (
FIRST_VALUE(subq_25.visits) OVER (
PARTITION BY
subq_26.user
, subq_26.ds__day
, subq_26.mf_internal_uuid
ORDER BY subq_23.ds__day DESC
subq_28.user
, subq_28.ds__day
, subq_28.mf_internal_uuid
ORDER BY subq_25.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS visits
, FIRST_VALUE(subq_23.ds__day) OVER (
, FIRST_VALUE(subq_25.ds__day) OVER (
PARTITION BY
subq_26.user
, subq_26.ds__day
, subq_26.mf_internal_uuid
ORDER BY subq_23.ds__day DESC
subq_28.user
, subq_28.ds__day
, subq_28.mf_internal_uuid
ORDER BY subq_25.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS ds__day
, FIRST_VALUE(subq_23.metric_time__day) OVER (
, FIRST_VALUE(subq_25.metric_time__day) OVER (
PARTITION BY
subq_26.user
, subq_26.ds__day
, subq_26.mf_internal_uuid
ORDER BY subq_23.ds__day DESC
subq_28.user
, subq_28.ds__day
, subq_28.mf_internal_uuid
ORDER BY subq_25.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS metric_time__day
, FIRST_VALUE(subq_23.user) OVER (
, FIRST_VALUE(subq_25.user) OVER (
PARTITION BY
subq_26.user
, subq_26.ds__day
, subq_26.mf_internal_uuid
ORDER BY subq_23.ds__day DESC
subq_28.user
, subq_28.ds__day
, subq_28.mf_internal_uuid
ORDER BY subq_25.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS user
, subq_26.mf_internal_uuid AS mf_internal_uuid
, subq_26.buys AS buys
, subq_28.mf_internal_uuid AS mf_internal_uuid
, subq_28.buys AS buys
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
-- Constrain Output with WHERE
-- Pass Only Elements: ['visits', 'ds__day', 'metric_time__day', 'user']
SELECT
DATETIME_TRUNC(ds, day) AS ds__day
, DATETIME_TRUNC(ds, day) AS metric_time__day
, user_id AS user
, 1 AS visits
FROM ***************************.fct_visits visits_source_src_28000
) subq_23
ds__day
, metric_time__day
, subq_23.user
, visits
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
SELECT
DATETIME_TRUNC(ds, day) AS ds__day
, DATETIME_TRUNC(ds, day) AS metric_time__day
, user_id AS user
, 1 AS visits
FROM ***************************.fct_visits visits_source_src_28000
) subq_23
WHERE metric_time__day = '2020-01-01'
) subq_25
INNER JOIN (
-- Read Elements From Semantic Model 'buys_source'
-- Metric Time Dimension 'ds'
Expand All @@ -92,19 +101,19 @@ FROM (
, 1 AS buys
, GENERATE_UUID() AS mf_internal_uuid
FROM ***************************.fct_buys buys_source_src_28000
) subq_26
) subq_28
ON
(
subq_23.user = subq_26.user
subq_25.user = subq_28.user
) AND (
(subq_23.ds__day <= subq_26.ds__day)
(subq_25.ds__day <= subq_28.ds__day)
)
) subq_27
) subq_29
GROUP BY
metric_time__day
) subq_30
) subq_32
ON
subq_20.metric_time__day = subq_30.metric_time__day
subq_21.metric_time__day = subq_32.metric_time__day
GROUP BY
metric_time__day
) subq_31
) subq_33
Loading

0 comments on commit 98d16f5

Please sign in to comment.