-
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
a2d0d59
commit c6306a6
Showing
36 changed files
with
12,822 additions
and
0 deletions.
There are no files selected for viewing
341 changes: 341 additions & 0 deletions
341
...ranularity.py/SqlQueryPlan/BigQuery/test_offset_metric_with_custom_granularity__plan0.sql
Large diffs are not rendered by default.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
....py/SqlQueryPlan/BigQuery/test_offset_metric_with_custom_granularity__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,37 @@ | ||
-- Compute Metrics via Expressions | ||
SELECT | ||
booking__ds__martian_day | ||
, bookings_5_days_ago AS bookings_5_day_lag | ||
FROM ( | ||
-- Pass Only Elements: ['bookings', 'booking__ds__day'] | ||
-- Join to Custom Granularity Dataset | ||
-- Pass Only Elements: ['bookings', 'booking__ds__martian_day'] | ||
-- Aggregate Measures | ||
-- Compute Metrics via Expressions | ||
SELECT | ||
subq_15.martian_day AS booking__ds__martian_day | ||
, SUM(subq_14.bookings) AS bookings_5_days_ago | ||
FROM ( | ||
-- Join to Time Spine Dataset | ||
SELECT | ||
subq_13.ds AS booking__ds__day | ||
, subq_11.bookings AS bookings | ||
FROM ***************************.mf_time_spine subq_13 | ||
INNER JOIN ( | ||
-- Read Elements From Semantic Model 'bookings_source' | ||
-- Metric Time Dimension 'ds' | ||
SELECT | ||
DATETIME_TRUNC(ds, day) AS booking__ds__day | ||
, 1 AS bookings | ||
FROM ***************************.fct_bookings bookings_source_src_28000 | ||
) subq_11 | ||
ON | ||
DATE_SUB(CAST(subq_13.ds AS DATETIME), INTERVAL 5 day) = subq_11.booking__ds__day | ||
) subq_14 | ||
LEFT OUTER JOIN | ||
***************************.mf_time_spine subq_15 | ||
ON | ||
subq_14.booking__ds__day = subq_15.ds | ||
GROUP BY | ||
booking__ds__martian_day | ||
) subq_19 |
349 changes: 349 additions & 0 deletions
349
...lan/BigQuery/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql
Large diffs are not rendered by default.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
...ry/test_offset_metric_with_custom_granularity_filter_not_in_group_by__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,45 @@ | ||
-- Compute Metrics via Expressions | ||
SELECT | ||
metric_time__day | ||
, bookings_5_days_ago AS bookings_5_day_lag | ||
FROM ( | ||
-- Constrain Output with WHERE | ||
-- Pass Only Elements: ['bookings', 'metric_time__day'] | ||
-- Aggregate Measures | ||
-- Compute Metrics via Expressions | ||
SELECT | ||
metric_time__day | ||
, SUM(bookings) AS bookings_5_days_ago | ||
FROM ( | ||
-- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__day'] | ||
-- Join to Custom Granularity Dataset | ||
SELECT | ||
subq_15.metric_time__day AS metric_time__day | ||
, subq_15.bookings AS bookings | ||
, subq_16.martian_day AS metric_time__martian_day | ||
FROM ( | ||
-- Join to Time Spine Dataset | ||
SELECT | ||
subq_14.ds AS metric_time__day | ||
, subq_12.bookings AS bookings | ||
FROM ***************************.mf_time_spine subq_14 | ||
INNER JOIN ( | ||
-- Read Elements From Semantic Model 'bookings_source' | ||
-- Metric Time Dimension 'ds' | ||
SELECT | ||
DATETIME_TRUNC(ds, day) AS metric_time__day | ||
, 1 AS bookings | ||
FROM ***************************.fct_bookings bookings_source_src_28000 | ||
) subq_12 | ||
ON | ||
DATE_SUB(CAST(subq_14.ds AS DATETIME), INTERVAL 5 day) = subq_12.metric_time__day | ||
) subq_15 | ||
LEFT OUTER JOIN | ||
***************************.mf_time_spine subq_16 | ||
ON | ||
subq_15.metric_time__day = subq_16.ds | ||
) subq_17 | ||
WHERE metric_time__martian_day = '2020-01-01' | ||
GROUP BY | ||
metric_time__day | ||
) subq_21 |
1,316 changes: 1,316 additions & 0 deletions
1,316
....py/SqlQueryPlan/BigQuery/test_simple_metric_with_multi_hop_custom_granularity__plan0.sql
Large diffs are not rendered by default.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
...ryPlan/BigQuery/test_simple_metric_with_multi_hop_custom_granularity__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,49 @@ | ||
-- Pass Only Elements: ['bookings', 'listing__user__ds__day'] | ||
-- Join to Custom Granularity Dataset | ||
-- Pass Only Elements: ['bookings', 'listing__user__ds__martian_day'] | ||
-- Aggregate Measures | ||
-- Compute Metrics via Expressions | ||
SELECT | ||
subq_26.martian_day AS listing__user__ds__martian_day | ||
, SUM(subq_25.bookings) AS bookings | ||
FROM ( | ||
-- Join Standard Outputs | ||
SELECT | ||
subq_24.user__ds__day AS listing__user__ds__day | ||
, subq_17.bookings AS bookings | ||
FROM ( | ||
-- Read Elements From Semantic Model 'bookings_source' | ||
-- Metric Time Dimension 'ds' | ||
-- Pass Only Elements: ['bookings', 'ds_partitioned__day', 'listing'] | ||
SELECT | ||
DATETIME_TRUNC(ds_partitioned, day) AS ds_partitioned__day | ||
, listing_id AS listing | ||
, 1 AS bookings | ||
FROM ***************************.fct_bookings bookings_source_src_28000 | ||
) subq_17 | ||
LEFT OUTER JOIN ( | ||
-- Join Standard Outputs | ||
-- Pass Only Elements: ['user__ds_partitioned__day', 'user__ds__day', 'listing'] | ||
SELECT | ||
DATETIME_TRUNC(users_ds_source_src_28000.ds, day) AS user__ds__day | ||
, DATETIME_TRUNC(users_ds_source_src_28000.ds_partitioned, day) AS user__ds_partitioned__day | ||
, listings_latest_src_28000.listing_id AS listing | ||
FROM ***************************.dim_listings_latest listings_latest_src_28000 | ||
LEFT OUTER JOIN | ||
***************************.dim_users users_ds_source_src_28000 | ||
ON | ||
listings_latest_src_28000.user_id = users_ds_source_src_28000.user_id | ||
) subq_24 | ||
ON | ||
( | ||
subq_17.listing = subq_24.listing | ||
) AND ( | ||
subq_17.ds_partitioned__day = subq_24.user__ds_partitioned__day | ||
) | ||
) subq_25 | ||
LEFT OUTER JOIN | ||
***************************.mf_time_spine subq_26 | ||
ON | ||
subq_25.listing__user__ds__day = subq_26.ds | ||
GROUP BY | ||
listing__user__ds__martian_day |
Oops, something went wrong.