Skip to content

Commit

Permalink
Generate snapshots for Trino
Browse files Browse the repository at this point in the history
This is a one-shot re-do of the snapshot generation for Trino
test cases originally done throughout @sarbmeetka's PR
(#810).

As explained earlier, these were split out to make it easier to
isolate the non-automated changes for any necessary updates in
CI testing.
  • Loading branch information
tlento committed Dec 19, 2023
1 parent e3fd61f commit d1fcc62
Show file tree
Hide file tree
Showing 202 changed files with 30,279 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
| metric_time__day | listing__capacity_latest | bookings | instant_bookings |
|:--------------------|---------------------------:|-----------:|-------------------:|
| 2019-12-01 00:00:00 | 5 | 1 | 0 |
| 2019-12-18 00:00:00 | 4 | 4 | 2 |
| 2019-12-19 00:00:00 | 4 | 6 | 6 |
| 2019-12-19 00:00:00 | 5 | 2 | 0 |
| 2019-12-20 00:00:00 | 5 | 2 | 0 |
| 2020-01-01 00:00:00 | 4 | 2 | 1 |
| 2020-01-02 00:00:00 | 4 | 3 | 3 |
| 2020-01-02 00:00:00 | 5 | 1 | 0 |
| 2020-01-03 00:00:00 | 5 | 1 | 0 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
| metric_time__day | trailing_2_months_revenue |
|:--------------------|----------------------------:|
| 2020-01-01 00:00:00 | 1000 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
| metric_time__day | listing__capacity_latest | bookings | instant_bookings |
|:--------------------|---------------------------:|-----------:|-------------------:|
| 2019-12-01 00:00:00 | 5 | 1 | 0 |
| 2019-12-18 00:00:00 | 4 | 4 | 2 |
| 2019-12-19 00:00:00 | 4 | 6 | 6 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
| metric_time__day | listing__capacity_latest | bookings | instant_bookings |
|:--------------------|---------------------------:|-----------:|-------------------:|
| 2019-12-01 00:00:00 | 5 | 1 | 0 |
| 2019-12-19 00:00:00 | 5 | 2 | 0 |
| 2019-12-20 00:00:00 | 5 | 2 | 0 |
| 2020-01-02 00:00:00 | 5 | 1 | 0 |
| 2020-01-03 00:00:00 | 5 | 1 | 0 |

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
-- Combine Aggregated Outputs
-- Compute Metrics via Expressions
SELECT
COALESCE(MAX(subq_28.buys), 0) AS visit_buy_conversions
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
-- Pass Only Elements:
-- ['visits']
-- Aggregate Measures
SELECT
SUM(1) AS visits
FROM ***************************.fct_visits visits_source_src_10011
) subq_18
CROSS JOIN (
-- Find conversions for user within the range of 7 day
-- Pass Only Elements:
-- ['buys']
-- Aggregate Measures
SELECT
SUM(buys) AS buys
FROM (
-- Dedupe the fanout with mf_internal_uuid in the conversion data set
SELECT DISTINCT
first_value(subq_21.visits) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS visits
, first_value(subq_21.ds__day) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS ds__day
, first_value(subq_21.user) OVER (PARTITION BY subq_24.user, subq_24.ds__day, subq_24.mf_internal_uuid ORDER BY subq_21.ds__day DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS user
, subq_24.mf_internal_uuid AS mf_internal_uuid
, subq_24.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('day', ds) AS ds__day
, user_id AS user
, 1 AS visits
FROM ***************************.fct_visits visits_source_src_10011
) subq_21
INNER JOIN (
-- Read Elements From Semantic Model 'buys_source'
-- Metric Time Dimension 'ds'
-- Add column with generated UUID
SELECT
DATE_TRUNC('day', ds) AS ds__day
, user_id AS user
, 1 AS buys
, uuid() AS mf_internal_uuid
FROM ***************************.fct_buys buys_source_src_10002
) subq_24
ON
(
subq_21.user = subq_24.user
) AND (
(
subq_21.ds__day <= subq_24.ds__day
) AND (
subq_21.ds__day > DATE_ADD('day', -7, subq_24.ds__day)
)
)
) subq_25
) subq_28
Loading

0 comments on commit d1fcc62

Please sign in to comment.