Skip to content

Commit

Permalink
Update SQL engine snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
tlento committed Jun 17, 2024
1 parent 431a9f7 commit 14f6b8c
Show file tree
Hide file tree
Showing 132 changed files with 17,590 additions and 23,710 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ SELECT
FROM (
-- Combine Aggregated Outputs
SELECT
COALESCE(subq_20.metric_time__day, subq_30.metric_time__day) AS metric_time__day
, COALESCE(subq_20.visit__referrer_id, subq_30.visit__referrer_id) AS visit__referrer_id
, MAX(subq_20.visits) AS visits
, MAX(subq_30.buys) AS buys
COALESCE(subq_21.metric_time__day, subq_31.metric_time__day) AS metric_time__day
, COALESCE(subq_21.visit__referrer_id, subq_31.visit__referrer_id) AS visit__referrer_id
, MAX(subq_21.visits) AS visits
, MAX(subq_31.buys) AS buys
FROM (
-- Constrain Output with WHERE
-- Aggregate Measures
Expand All @@ -18,20 +18,28 @@ FROM (
, visit__referrer_id
, SUM(visits) AS visits
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
-- Constrain Output with WHERE
-- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day']
SELECT
DATETIME_TRUNC(ds, day) AS metric_time__day
, referrer_id AS visit__referrer_id
, 1 AS visits
FROM ***************************.fct_visits visits_source_src_28000
) subq_18
metric_time__day
, visit__referrer_id
, visits
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
SELECT
DATETIME_TRUNC(ds, day) AS metric_time__day
, referrer_id AS visit__referrer_id
, 1 AS visits
FROM ***************************.fct_visits visits_source_src_28000
) subq_17
WHERE visit__referrer_id = 'ref_id_01'
) subq_19
WHERE visit__referrer_id = 'ref_id_01'
GROUP BY
metric_time__day
, visit__referrer_id
) subq_20
) subq_21
FULL OUTER JOIN (
-- Find conversions for user within the range of INF
-- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day']
Expand All @@ -43,48 +51,48 @@ 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_24.visits) OVER (
PARTITION BY
subq_26.user
, subq_26.ds__day
, subq_26.mf_internal_uuid
ORDER BY subq_23.ds__day DESC
subq_27.user
, subq_27.ds__day
, subq_27.mf_internal_uuid
ORDER BY subq_24.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS visits
, first_value(subq_23.visit__referrer_id) OVER (
, first_value(subq_24.visit__referrer_id) OVER (
PARTITION BY
subq_26.user
, subq_26.ds__day
, subq_26.mf_internal_uuid
ORDER BY subq_23.ds__day DESC
subq_27.user
, subq_27.ds__day
, subq_27.mf_internal_uuid
ORDER BY subq_24.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS visit__referrer_id
, first_value(subq_23.ds__day) OVER (
, first_value(subq_24.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_27.user
, subq_27.ds__day
, subq_27.mf_internal_uuid
ORDER BY subq_24.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS ds__day
, first_value(subq_23.metric_time__day) OVER (
, first_value(subq_24.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_27.user
, subq_27.ds__day
, subq_27.mf_internal_uuid
ORDER BY subq_24.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS metric_time__day
, first_value(subq_23.user) OVER (
, first_value(subq_24.user) OVER (
PARTITION BY
subq_26.user
, subq_26.ds__day
, subq_26.mf_internal_uuid
ORDER BY subq_23.ds__day DESC
subq_27.user
, subq_27.ds__day
, subq_27.mf_internal_uuid
ORDER BY subq_24.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_27.mf_internal_uuid AS mf_internal_uuid
, subq_27.buys AS buys
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
Expand All @@ -96,7 +104,7 @@ FROM (
, referrer_id AS visit__referrer_id
, 1 AS visits
FROM ***************************.fct_visits visits_source_src_28000
) subq_23
) subq_24
INNER JOIN (
-- Read Elements From Semantic Model 'buys_source'
-- Metric Time Dimension 'ds'
Expand All @@ -107,25 +115,25 @@ FROM (
, 1 AS buys
, GENERATE_UUID() AS mf_internal_uuid
FROM ***************************.fct_buys buys_source_src_28000
) subq_26
) subq_27
ON
(
subq_23.user = subq_26.user
subq_24.user = subq_27.user
) AND (
(subq_23.ds__day <= subq_26.ds__day)
(subq_24.ds__day <= subq_27.ds__day)
)
) subq_27
) subq_28
GROUP BY
metric_time__day
, visit__referrer_id
) subq_30
) subq_31
ON
(
subq_20.visit__referrer_id = subq_30.visit__referrer_id
subq_21.visit__referrer_id = subq_31.visit__referrer_id
) AND (
subq_20.metric_time__day = subq_30.metric_time__day
subq_21.metric_time__day = subq_31.metric_time__day
)
GROUP BY
metric_time__day
, visit__referrer_id
) subq_31
) subq_32
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,41 @@ SELECT
FROM (
-- Combine Aggregated Outputs
SELECT
COALESCE(subq_23.visit__referrer_id, subq_34.visit__referrer_id) AS visit__referrer_id
, MAX(subq_23.visits) AS visits
, MAX(subq_34.buys) AS buys
COALESCE(subq_24.visit__referrer_id, subq_35.visit__referrer_id) AS visit__referrer_id
, MAX(subq_24.visits) AS visits
, MAX(subq_35.buys) AS buys
FROM (
-- Constrain Output with WHERE
-- Aggregate Measures
SELECT
visit__referrer_id
, SUM(visits) AS visits
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
-- Constrain Output with WHERE
-- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00]
-- Pass Only Elements: ['visits', 'visit__referrer_id']
SELECT
referrer_id AS visit__referrer_id
, 1 AS visits
FROM ***************************.fct_visits visits_source_src_28000
WHERE DATETIME_TRUNC(ds, day) BETWEEN '2020-01-01' AND '2020-01-02'
) subq_21
visit__referrer_id
, visits
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
SELECT
DATETIME_TRUNC(ds, day) AS metric_time__day
, referrer_id AS visit__referrer_id
, 1 AS visits
FROM ***************************.fct_visits visits_source_src_28000
) subq_19
WHERE (
metric_time__day BETWEEN '2020-01-01' AND '2020-01-02'
) AND (
visit__referrer_id = 'ref_id_01'
)
) subq_22
WHERE visit__referrer_id = 'ref_id_01'
GROUP BY
visit__referrer_id
) subq_23
) subq_24
FULL OUTER JOIN (
-- Find conversions for user within the range of INF
-- Pass Only Elements: ['buys', 'visit__referrer_id']
Expand All @@ -39,40 +50,40 @@ FROM (
FROM (
-- Dedupe the fanout with mf_internal_uuid in the conversion data set
SELECT DISTINCT
first_value(subq_27.visits) OVER (
first_value(subq_28.visits) OVER (
PARTITION BY
subq_30.user
, subq_30.ds__day
, subq_30.mf_internal_uuid
ORDER BY subq_27.ds__day DESC
subq_31.user
, subq_31.ds__day
, subq_31.mf_internal_uuid
ORDER BY subq_28.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS visits
, first_value(subq_27.visit__referrer_id) OVER (
, first_value(subq_28.visit__referrer_id) OVER (
PARTITION BY
subq_30.user
, subq_30.ds__day
, subq_30.mf_internal_uuid
ORDER BY subq_27.ds__day DESC
subq_31.user
, subq_31.ds__day
, subq_31.mf_internal_uuid
ORDER BY subq_28.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS visit__referrer_id
, first_value(subq_27.ds__day) OVER (
, first_value(subq_28.ds__day) OVER (
PARTITION BY
subq_30.user
, subq_30.ds__day
, subq_30.mf_internal_uuid
ORDER BY subq_27.ds__day DESC
subq_31.user
, subq_31.ds__day
, subq_31.mf_internal_uuid
ORDER BY subq_28.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS ds__day
, first_value(subq_27.user) OVER (
, first_value(subq_28.user) OVER (
PARTITION BY
subq_30.user
, subq_30.ds__day
, subq_30.mf_internal_uuid
ORDER BY subq_27.ds__day DESC
subq_31.user
, subq_31.ds__day
, subq_31.mf_internal_uuid
ORDER BY subq_28.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS user
, subq_30.mf_internal_uuid AS mf_internal_uuid
, subq_30.buys AS buys
, subq_31.mf_internal_uuid AS mf_internal_uuid
, subq_31.buys AS buys
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
Expand All @@ -85,7 +96,7 @@ FROM (
, 1 AS visits
FROM ***************************.fct_visits visits_source_src_28000
WHERE DATETIME_TRUNC(ds, day) BETWEEN '2020-01-01' AND '2020-01-02'
) subq_27
) subq_28
INNER JOIN (
-- Read Elements From Semantic Model 'buys_source'
-- Metric Time Dimension 'ds'
Expand All @@ -96,19 +107,19 @@ FROM (
, 1 AS buys
, GENERATE_UUID() AS mf_internal_uuid
FROM ***************************.fct_buys buys_source_src_28000
) subq_30
) subq_31
ON
(
subq_27.user = subq_30.user
subq_28.user = subq_31.user
) AND (
(subq_27.ds__day <= subq_30.ds__day)
(subq_28.ds__day <= subq_31.ds__day)
)
) subq_31
) subq_32
GROUP BY
visit__referrer_id
) subq_34
) subq_35
ON
subq_23.visit__referrer_id = subq_34.visit__referrer_id
subq_24.visit__referrer_id = subq_35.visit__referrer_id
GROUP BY
visit__referrer_id
) subq_35
) subq_36
Loading

0 comments on commit 14f6b8c

Please sign in to comment.