-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d5b10b
commit 0dc7eef
Showing
24 changed files
with
6,222 additions
and
0 deletions.
There are no files selected for viewing
555 changes: 555 additions & 0 deletions
555
...c_filter_rendering.py/SqlQueryPlan/BigQuery/test_filter_with_conversion_metric__plan0.sql
Large diffs are not rendered by default.
Oops, something went wrong.
120 changes: 120 additions & 0 deletions
120
...endering.py/SqlQueryPlan/BigQuery/test_filter_with_conversion_metric__plan0_optimized.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
318 changes: 318 additions & 0 deletions
318
...lter_rendering.py/SqlQueryPlan/BigQuery/test_group_by_has_local_entity_prefix2__plan0.sql
Large diffs are not rendered by default.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
...ring.py/SqlQueryPlan/BigQuery/test_group_by_has_local_entity_prefix2__plan0_optimized.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.