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 Oct 18, 2024
1 parent a2d0d59 commit c6306a6
Show file tree
Hide file tree
Showing 36 changed files with 12,822 additions and 0 deletions.

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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
Loading

0 comments on commit c6306a6

Please sign in to comment.