Skip to content

Commit

Permalink
Update SQL engine snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed May 10, 2024
1 parent 4d5b10b commit 0dc7eef
Show file tree
Hide file tree
Showing 24 changed files with 6,222 additions and 0 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
-- Constrain Output with WHERE
-- Pass Only Elements: ['listings',]
-- Aggregate Measures
-- Compute Metrics via Expressions
SELECT
SUM(listings) AS listings
FROM (
-- Join Standard Outputs
-- Pass Only Elements: ['listings', 'user__visit_buy_conversion_rate']
SELECT
CAST(subq_57.buys AS FLOAT64) / CAST(NULLIF(subq_57.visits, 0) AS FLOAT64) AS user__visit_buy_conversion_rate
, subq_42.listings AS listings
FROM (
-- Read Elements From Semantic Model 'listings_latest'
-- Metric Time Dimension 'ds'
-- Pass Only Elements: ['listings', 'user']
SELECT
user_id AS user
, 1 AS listings
FROM ***************************.dim_listings_latest listings_latest_src_28000
) subq_42
LEFT OUTER JOIN (
-- Combine Aggregated Outputs
SELECT
COALESCE(subq_46.user, subq_56.user) AS user
, MAX(subq_46.visits) AS visits
, MAX(subq_56.buys) AS buys
FROM (
-- Aggregate Measures
SELECT
subq_45.user
, SUM(visits) AS visits
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
-- Pass Only Elements: ['visits', 'user']
SELECT
user_id AS user
, 1 AS visits
FROM ***************************.fct_visits visits_source_src_28000
) subq_45
GROUP BY
user
) subq_46
FULL OUTER JOIN (
-- Find conversions for user within the range of INF
-- Pass Only Elements: ['buys', 'user']
-- Aggregate Measures
SELECT
subq_53.user
, SUM(buys) AS buys
FROM (
-- Dedupe the fanout with mf_internal_uuid in the conversion data set
SELECT DISTINCT
first_value(subq_49.visits) OVER (
PARTITION BY
subq_52.user
, subq_52.ds__day
, subq_52.mf_internal_uuid
ORDER BY subq_49.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS visits
, first_value(subq_49.ds__day) OVER (
PARTITION BY
subq_52.user
, subq_52.ds__day
, subq_52.mf_internal_uuid
ORDER BY subq_49.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS ds__day
, first_value(subq_49.user) OVER (
PARTITION BY
subq_52.user
, subq_52.ds__day
, subq_52.mf_internal_uuid
ORDER BY subq_49.ds__day DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
) AS user
, subq_52.mf_internal_uuid AS mf_internal_uuid
, subq_52.buys AS buys
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
-- Pass Only Elements: ['visits', 'ds__day', 'user']
SELECT
DATE_TRUNC(ds, day) AS ds__day
, user_id AS user
, 1 AS visits
FROM ***************************.fct_visits visits_source_src_28000
) subq_49
INNER JOIN (
-- Read Elements From Semantic Model 'buys_source'
-- Metric Time Dimension 'ds'
-- Add column with generated UUID
SELECT
DATE_TRUNC(ds, day) AS ds__day
, user_id AS user
, 1 AS buys
, GENERATE_UUID() AS mf_internal_uuid
FROM ***************************.fct_buys buys_source_src_28000
) subq_52
ON
(
subq_49.user = subq_52.user
) AND (
(subq_49.ds__day <= subq_52.ds__day)
)
) subq_53
GROUP BY
user
) subq_56
ON
subq_46.user = subq_56.user
GROUP BY
user
) subq_57
ON
subq_42.user = subq_57.user
) subq_61
WHERE user__visit_buy_conversion_rate > 2

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
-- Constrain Output with WHERE
-- Pass Only Elements: ['listings',]
-- Aggregate Measures
-- Compute Metrics via Expressions
SELECT
SUM(listings) AS listings
FROM (
-- Join Standard Outputs
-- Pass Only Elements: ['listings', 'listing__view__listing__views']
SELECT
subq_26.view__listing__views AS listing__view__listing__views
, subq_20.listings AS listings
FROM (
-- Read Elements From Semantic Model 'listings_latest'
-- Metric Time Dimension 'ds'
-- Pass Only Elements: ['listings', 'listing']
SELECT
listing_id AS listing
, 1 AS listings
FROM ***************************.dim_listings_latest listings_latest_src_28000
) subq_20
LEFT OUTER JOIN (
-- Aggregate Measures
-- Compute Metrics via Expressions
-- Pass Only Elements: ['view__listing', 'view__listing__views']
SELECT
view__listing
, SUM(views) AS view__listing__views
FROM (
-- Read Elements From Semantic Model 'views_source'
-- Metric Time Dimension 'ds'
-- Pass Only Elements: ['views', 'view__listing']
SELECT
listing_id AS view__listing
, 1 AS views
FROM ***************************.fct_views views_source_src_28000
) subq_23
GROUP BY
view__listing
) subq_26
ON
subq_20.listing = subq_26.view__listing
) subq_28
WHERE listing__view__listing__views > 2
Loading

0 comments on commit 0dc7eef

Please sign in to comment.