Skip to content

Commit

Permalink
Update SQL snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Nov 16, 2023
1 parent ad5dec1 commit ac56a58
Show file tree
Hide file tree
Showing 20 changed files with 4,595 additions and 0 deletions.

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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
Loading

0 comments on commit ac56a58

Please sign in to comment.