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 26, 2024
1 parent a00cf80 commit e87aa80
Show file tree
Hide file tree
Showing 78 changed files with 1,929 additions and 2,619 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,32 @@ SELECT
FROM (
-- Combine Aggregated Outputs
SELECT
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
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
FROM (
-- Constrain Output with WHERE
-- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day']
-- Aggregate Measures
SELECT
metric_time__day
, visit__referrer_id
, SUM(visits) AS visits
FROM (
-- Constrain Output with WHERE
-- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day']
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
SELECT
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
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'
GROUP BY
metric_time__day
, visit__referrer_id
) subq_21
) subq_20
FULL OUTER JOIN (
-- Find conversions for user within the range of INF
-- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day']
Expand All @@ -51,48 +43,48 @@ FROM (
FROM (
-- Dedupe the fanout with mf_internal_uuid in the conversion data set
SELECT DISTINCT
FIRST_VALUE(subq_24.visits) OVER (
FIRST_VALUE(subq_23.visits) OVER (
PARTITION BY
subq_27.user
, subq_27.ds__day
, subq_27.mf_internal_uuid
ORDER BY subq_24.ds__day DESC
subq_26.user
, subq_26.ds__day
, subq_26.mf_internal_uuid
ORDER BY subq_23.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS visits
, FIRST_VALUE(subq_24.visit__referrer_id) OVER (
, FIRST_VALUE(subq_23.visit__referrer_id) OVER (
PARTITION BY
subq_27.user
, subq_27.ds__day
, subq_27.mf_internal_uuid
ORDER BY subq_24.ds__day DESC
subq_26.user
, subq_26.ds__day
, subq_26.mf_internal_uuid
ORDER BY subq_23.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS visit__referrer_id
, FIRST_VALUE(subq_24.ds__day) OVER (
, FIRST_VALUE(subq_23.ds__day) OVER (
PARTITION BY
subq_27.user
, subq_27.ds__day
, subq_27.mf_internal_uuid
ORDER BY subq_24.ds__day DESC
subq_26.user
, subq_26.ds__day
, subq_26.mf_internal_uuid
ORDER BY subq_23.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS ds__day
, FIRST_VALUE(subq_24.metric_time__day) OVER (
, FIRST_VALUE(subq_23.metric_time__day) OVER (
PARTITION BY
subq_27.user
, subq_27.ds__day
, subq_27.mf_internal_uuid
ORDER BY subq_24.ds__day DESC
subq_26.user
, subq_26.ds__day
, subq_26.mf_internal_uuid
ORDER BY subq_23.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS metric_time__day
, FIRST_VALUE(subq_24.user) OVER (
, FIRST_VALUE(subq_23.user) OVER (
PARTITION BY
subq_27.user
, subq_27.ds__day
, subq_27.mf_internal_uuid
ORDER BY subq_24.ds__day DESC
subq_26.user
, subq_26.ds__day
, subq_26.mf_internal_uuid
ORDER BY subq_23.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS user
, subq_27.mf_internal_uuid AS mf_internal_uuid
, subq_27.buys AS buys
, subq_26.mf_internal_uuid AS mf_internal_uuid
, subq_26.buys AS buys
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
Expand All @@ -104,7 +96,7 @@ FROM (
, referrer_id AS visit__referrer_id
, 1 AS visits
FROM ***************************.fct_visits visits_source_src_28000
) subq_24
) subq_23
INNER JOIN (
-- Read Elements From Semantic Model 'buys_source'
-- Metric Time Dimension 'ds'
Expand All @@ -115,25 +107,25 @@ FROM (
, 1 AS buys
, GENERATE_UUID() AS mf_internal_uuid
FROM ***************************.fct_buys buys_source_src_28000
) subq_27
) subq_26
ON
(
subq_24.user = subq_27.user
subq_23.user = subq_26.user
) AND (
(subq_24.ds__day <= subq_27.ds__day)
(subq_23.ds__day <= subq_26.ds__day)
)
) subq_28
) subq_27
GROUP BY
metric_time__day
, visit__referrer_id
) subq_31
) subq_30
ON
(
subq_21.visit__referrer_id = subq_31.visit__referrer_id
subq_20.visit__referrer_id = subq_30.visit__referrer_id
) AND (
subq_21.metric_time__day = subq_31.metric_time__day
subq_20.metric_time__day = subq_30.metric_time__day
)
GROUP BY
metric_time__day
, visit__referrer_id
) subq_32
) subq_31
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,34 @@ SELECT
FROM (
-- Combine Aggregated Outputs
SELECT
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
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
FROM (
-- 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']
-- Aggregate Measures
SELECT
visit__referrer_id
, SUM(visits) AS visits
FROM (
-- 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']
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
SELECT
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'
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'
)
GROUP BY
visit__referrer_id
) subq_24
) subq_23
FULL OUTER JOIN (
-- Find conversions for user within the range of INF
-- Pass Only Elements: ['buys', 'visit__referrer_id']
Expand All @@ -50,40 +43,40 @@ FROM (
FROM (
-- Dedupe the fanout with mf_internal_uuid in the conversion data set
SELECT DISTINCT
FIRST_VALUE(subq_28.visits) OVER (
FIRST_VALUE(subq_27.visits) OVER (
PARTITION BY
subq_31.user
, subq_31.ds__day
, subq_31.mf_internal_uuid
ORDER BY subq_28.ds__day DESC
subq_30.user
, subq_30.ds__day
, subq_30.mf_internal_uuid
ORDER BY subq_27.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS visits
, FIRST_VALUE(subq_28.visit__referrer_id) OVER (
, FIRST_VALUE(subq_27.visit__referrer_id) OVER (
PARTITION BY
subq_31.user
, subq_31.ds__day
, subq_31.mf_internal_uuid
ORDER BY subq_28.ds__day DESC
subq_30.user
, subq_30.ds__day
, subq_30.mf_internal_uuid
ORDER BY subq_27.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS visit__referrer_id
, FIRST_VALUE(subq_28.ds__day) OVER (
, FIRST_VALUE(subq_27.ds__day) OVER (
PARTITION BY
subq_31.user
, subq_31.ds__day
, subq_31.mf_internal_uuid
ORDER BY subq_28.ds__day DESC
subq_30.user
, subq_30.ds__day
, subq_30.mf_internal_uuid
ORDER BY subq_27.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS ds__day
, FIRST_VALUE(subq_28.user) OVER (
, FIRST_VALUE(subq_27.user) OVER (
PARTITION BY
subq_31.user
, subq_31.ds__day
, subq_31.mf_internal_uuid
ORDER BY subq_28.ds__day DESC
subq_30.user
, subq_30.ds__day
, subq_30.mf_internal_uuid
ORDER BY subq_27.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS user
, subq_31.mf_internal_uuid AS mf_internal_uuid
, subq_31.buys AS buys
, subq_30.mf_internal_uuid AS mf_internal_uuid
, subq_30.buys AS buys
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
Expand All @@ -96,7 +89,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_28
) subq_27
INNER JOIN (
-- Read Elements From Semantic Model 'buys_source'
-- Metric Time Dimension 'ds'
Expand All @@ -107,19 +100,19 @@ FROM (
, 1 AS buys
, GENERATE_UUID() AS mf_internal_uuid
FROM ***************************.fct_buys buys_source_src_28000
) subq_31
) subq_30
ON
(
subq_28.user = subq_31.user
subq_27.user = subq_30.user
) AND (
(subq_28.ds__day <= subq_31.ds__day)
(subq_27.ds__day <= subq_30.ds__day)
)
) subq_32
) subq_31
GROUP BY
visit__referrer_id
) subq_35
) subq_34
ON
subq_24.visit__referrer_id = subq_35.visit__referrer_id
subq_23.visit__referrer_id = subq_34.visit__referrer_id
GROUP BY
visit__referrer_id
) subq_36
) subq_35
Loading

0 comments on commit e87aa80

Please sign in to comment.