-
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
ad5dec1
commit ac56a58
Showing
20 changed files
with
4,595 additions
and
0 deletions.
There are no files selected for viewing
473 changes: 473 additions & 0 deletions
473
...eryPlan/BigQuery/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql
Large diffs are not rendered by default.
Oops, something went wrong.
64 changes: 64 additions & 0 deletions
64
...gQuery/test_nested_derived_metric_with_offset_multiple_input_metrics__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,64 @@ | ||
-- Compute Metrics via Expressions | ||
SELECT | ||
metric_time__day | ||
, booking_fees - booking_fees_start_of_month AS booking_fees_since_start_of_month | ||
FROM ( | ||
-- Combine Metrics | ||
SELECT | ||
COALESCE(subq_24.metric_time__day, subq_30.metric_time__day) AS metric_time__day | ||
, MAX(subq_24.booking_fees_start_of_month) AS booking_fees_start_of_month | ||
, MAX(subq_30.booking_fees) AS booking_fees | ||
FROM ( | ||
-- Join to Time Spine Dataset | ||
SELECT | ||
subq_23.ds AS metric_time__day | ||
, subq_21.booking_fees_start_of_month AS booking_fees_start_of_month | ||
FROM ***************************.mf_time_spine subq_23 | ||
INNER JOIN ( | ||
-- Compute Metrics via Expressions | ||
SELECT | ||
metric_time__day | ||
, booking_value * 0.05 AS booking_fees_start_of_month | ||
FROM ( | ||
-- Read Elements From Semantic Model 'bookings_source' | ||
-- Metric Time Dimension 'ds' | ||
-- Pass Only Elements: | ||
-- ['booking_value', 'metric_time__day'] | ||
-- Aggregate Measures | ||
-- Compute Metrics via Expressions | ||
SELECT | ||
DATE_TRUNC(ds, day) AS metric_time__day | ||
, SUM(booking_value) AS booking_value | ||
FROM ***************************.fct_bookings bookings_source_src_10001 | ||
GROUP BY | ||
metric_time__day | ||
) subq_20 | ||
) subq_21 | ||
ON | ||
DATE_TRUNC(subq_23.ds, month) = subq_21.metric_time__day | ||
) subq_24 | ||
FULL OUTER JOIN ( | ||
-- Compute Metrics via Expressions | ||
SELECT | ||
metric_time__day | ||
, booking_value * 0.05 AS booking_fees | ||
FROM ( | ||
-- Read Elements From Semantic Model 'bookings_source' | ||
-- Metric Time Dimension 'ds' | ||
-- Pass Only Elements: | ||
-- ['booking_value', 'metric_time__day'] | ||
-- Aggregate Measures | ||
-- Compute Metrics via Expressions | ||
SELECT | ||
DATE_TRUNC(ds, day) AS metric_time__day | ||
, SUM(booking_value) AS booking_value | ||
FROM ***************************.fct_bookings bookings_source_src_10001 | ||
GROUP BY | ||
metric_time__day | ||
) subq_29 | ||
) subq_30 | ||
ON | ||
subq_24.metric_time__day = subq_30.metric_time__day | ||
GROUP BY | ||
metric_time__day | ||
) subq_31 |
340 changes: 340 additions & 0 deletions
340
...apshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_nested_offsets__plan0.sql
Large diffs are not rendered by default.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
...st_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_nested_offsets__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,42 @@ | ||
-- Compute Metrics via Expressions | ||
SELECT | ||
metric_time__day | ||
, 2 * bookings_offset_once AS bookings_offset_twice | ||
FROM ( | ||
-- Join to Time Spine Dataset | ||
SELECT | ||
subq_22.ds AS metric_time__day | ||
, subq_20.bookings_offset_once AS bookings_offset_once | ||
FROM ***************************.mf_time_spine subq_22 | ||
INNER JOIN ( | ||
-- Compute Metrics via Expressions | ||
SELECT | ||
metric_time__day | ||
, 2 * bookings AS bookings_offset_once | ||
FROM ( | ||
-- Join to Time Spine Dataset | ||
-- Pass Only Elements: | ||
-- ['bookings', 'metric_time__day'] | ||
-- Aggregate Measures | ||
-- Compute Metrics via Expressions | ||
SELECT | ||
subq_15.ds AS metric_time__day | ||
, SUM(subq_13.bookings) AS bookings | ||
FROM ***************************.mf_time_spine subq_15 | ||
INNER JOIN ( | ||
-- Read Elements From Semantic Model 'bookings_source' | ||
-- Metric Time Dimension 'ds' | ||
SELECT | ||
DATE_TRUNC(ds, day) AS metric_time__day | ||
, 1 AS bookings | ||
FROM ***************************.fct_bookings bookings_source_src_10001 | ||
) subq_13 | ||
ON | ||
DATE_SUB(CAST(subq_15.ds AS DATETIME), INTERVAL 5 day) = subq_13.metric_time__day | ||
GROUP BY | ||
metric_time__day | ||
) subq_19 | ||
) subq_20 | ||
ON | ||
DATE_SUB(CAST(subq_22.ds AS DATETIME), INTERVAL 5 day) = subq_20.metric_time__day | ||
) subq_23 |
473 changes: 473 additions & 0 deletions
473
...yPlan/Databricks/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql
Large diffs are not rendered by default.
Oops, something went wrong.
64 changes: 64 additions & 0 deletions
64
...bricks/test_nested_derived_metric_with_offset_multiple_input_metrics__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,64 @@ | ||
-- Compute Metrics via Expressions | ||
SELECT | ||
metric_time__day | ||
, booking_fees - booking_fees_start_of_month AS booking_fees_since_start_of_month | ||
FROM ( | ||
-- Combine Metrics | ||
SELECT | ||
COALESCE(subq_24.metric_time__day, subq_30.metric_time__day) AS metric_time__day | ||
, MAX(subq_24.booking_fees_start_of_month) AS booking_fees_start_of_month | ||
, MAX(subq_30.booking_fees) AS booking_fees | ||
FROM ( | ||
-- Join to Time Spine Dataset | ||
SELECT | ||
subq_23.ds AS metric_time__day | ||
, subq_21.booking_fees_start_of_month AS booking_fees_start_of_month | ||
FROM ***************************.mf_time_spine subq_23 | ||
INNER JOIN ( | ||
-- Compute Metrics via Expressions | ||
SELECT | ||
metric_time__day | ||
, booking_value * 0.05 AS booking_fees_start_of_month | ||
FROM ( | ||
-- Read Elements From Semantic Model 'bookings_source' | ||
-- Metric Time Dimension 'ds' | ||
-- Pass Only Elements: | ||
-- ['booking_value', 'metric_time__day'] | ||
-- Aggregate Measures | ||
-- Compute Metrics via Expressions | ||
SELECT | ||
DATE_TRUNC('day', ds) AS metric_time__day | ||
, SUM(booking_value) AS booking_value | ||
FROM ***************************.fct_bookings bookings_source_src_10001 | ||
GROUP BY | ||
DATE_TRUNC('day', ds) | ||
) subq_20 | ||
) subq_21 | ||
ON | ||
DATE_TRUNC('month', subq_23.ds) = subq_21.metric_time__day | ||
) subq_24 | ||
FULL OUTER JOIN ( | ||
-- Compute Metrics via Expressions | ||
SELECT | ||
metric_time__day | ||
, booking_value * 0.05 AS booking_fees | ||
FROM ( | ||
-- Read Elements From Semantic Model 'bookings_source' | ||
-- Metric Time Dimension 'ds' | ||
-- Pass Only Elements: | ||
-- ['booking_value', 'metric_time__day'] | ||
-- Aggregate Measures | ||
-- Compute Metrics via Expressions | ||
SELECT | ||
DATE_TRUNC('day', ds) AS metric_time__day | ||
, SUM(booking_value) AS booking_value | ||
FROM ***************************.fct_bookings bookings_source_src_10001 | ||
GROUP BY | ||
DATE_TRUNC('day', ds) | ||
) subq_29 | ||
) subq_30 | ||
ON | ||
subq_24.metric_time__day = subq_30.metric_time__day | ||
GROUP BY | ||
COALESCE(subq_24.metric_time__day, subq_30.metric_time__day) | ||
) subq_31 |
Oops, something went wrong.