Skip to content

Commit

Permalink
fixup! WIP - evaluating snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Nov 22, 2024
1 parent 4d145e8 commit 05af31e
Show file tree
Hide file tree
Showing 126 changed files with 276 additions and 266 deletions.
10 changes: 4 additions & 6 deletions metricflow/dataset/convert_semantic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,13 +528,11 @@ def build_time_spine_source_data_set(self, time_spine_source: TimeSpineSource) -
time_granularity=ExpandedTimeGranularity.from_time_granularity(base_granularity),
)
time_dimension_instances.append(base_time_dimension_instance)
base_dimension_select_expr = SemanticModelToDataSetConverter._make_element_sql_expr(
table_alias=from_source_alias, element_name=base_column_name
base_dimension_select_expr = SqlColumnReferenceExpression.from_table_and_column_names(
table_alias=from_source_alias, column_name=base_column_name
)
base_select_column = self._build_column_for_standard_time_granularity(
time_granularity=base_granularity,
expr=base_dimension_select_expr,
column_alias=base_time_dimension_instance.associated_column.column_name,
base_select_column = SqlSelectColumn(
expr=base_dimension_select_expr, column_alias=base_time_dimension_instance.associated_column.column_name
)
select_columns.append(base_select_column)
new_base_instances, new_base_columns = self._build_time_dimension_instances_and_columns(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ FROM (
FROM (
-- Read From Time Spine 'mf_time_spine'
SELECT
DATE_TRUNC('day', time_spine_src_28006.ds) AS ds__day
time_spine_src_28006.ds AS ds__day
, DATE_TRUNC('week', time_spine_src_28006.ds) AS ds__week
, DATE_TRUNC('month', time_spine_src_28006.ds) AS ds__month
, DATE_TRUNC('quarter', time_spine_src_28006.ds) AS ds__quarter
Expand Down Expand Up @@ -161,7 +161,7 @@ FROM (
FROM (
-- Read From Time Spine 'mf_time_spine'
SELECT
DATE_TRUNC('day', time_spine_src_28006.ds) AS ds__day
time_spine_src_28006.ds AS ds__day
, DATE_TRUNC('week', time_spine_src_28006.ds) AS ds__week
, DATE_TRUNC('month', time_spine_src_28006.ds) AS ds__month
, DATE_TRUNC('quarter', time_spine_src_28006.ds) AS ds__quarter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ FROM (
FROM (
-- Join to Time Spine Dataset
SELECT
DATE_TRUNC('day', time_spine_src_28006.ds) AS metric_time__day
time_spine_src_28006.ds AS metric_time__day
, subq_26.visits AS visits
FROM ***************************.mf_time_spine time_spine_src_28006
LEFT OUTER JOIN (
Expand All @@ -42,12 +42,12 @@ FROM (
metric_time__day
) subq_26
ON
DATE_TRUNC('day', time_spine_src_28006.ds) = subq_26.metric_time__day
time_spine_src_28006.ds = subq_26.metric_time__day
) subq_30
FULL OUTER JOIN (
-- Join to Time Spine Dataset
SELECT
DATE_TRUNC('day', time_spine_src_28006.ds) AS metric_time__day
time_spine_src_28006.ds AS metric_time__day
, subq_39.buys AS buys
FROM ***************************.mf_time_spine time_spine_src_28006
LEFT OUTER JOIN (
Expand Down Expand Up @@ -113,7 +113,7 @@ FROM (
metric_time__day
) subq_39
ON
DATE_TRUNC('day', time_spine_src_28006.ds) = subq_39.metric_time__day
time_spine_src_28006.ds = subq_39.metric_time__day
) subq_43
ON
subq_30.metric_time__day = subq_43.metric_time__day
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,25 @@ docstring:
<SqlSelectStatementNode>
<!-- description = "Read From Time Spine 'mf_time_spine'" -->
<!-- node_id = NodeId(id_str='ss_4') -->
<!-- col0 = -->
<!-- SqlSelectColumn(expr=SqlDateTruncExpression(node_id=dt_28293), column_alias='ds__day') -->
<!-- col0 = -->
<!-- SqlSelectColumn( -->
<!-- expr=SqlColumnReferenceExpression(node_id=cr_28130), -->
<!-- column_alias='ds__day', -->
<!-- ) -->
<!-- col1 = -->
<!-- SqlSelectColumn(expr=SqlDateTruncExpression(node_id=dt_28294), column_alias='ds__week') -->
<!-- SqlSelectColumn(expr=SqlDateTruncExpression(node_id=dt_28287), column_alias='ds__week') -->
<!-- col2 = -->
<!-- SqlSelectColumn( -->
<!-- expr=SqlDateTruncExpression(node_id=dt_28295), -->
<!-- expr=SqlDateTruncExpression(node_id=dt_28288), -->
<!-- column_alias='ds__month', -->
<!-- ) -->
<!-- col3 = -->
<!-- SqlSelectColumn( -->
<!-- expr=SqlDateTruncExpression(node_id=dt_28296), -->
<!-- expr=SqlDateTruncExpression(node_id=dt_28289), -->
<!-- column_alias='ds__quarter', -->
<!-- ) -->
<!-- col4 = -->
<!-- SqlSelectColumn(expr=SqlDateTruncExpression(node_id=dt_28297), column_alias='ds__year') -->
<!-- SqlSelectColumn(expr=SqlDateTruncExpression(node_id=dt_28290), column_alias='ds__year') -->
<!-- col5 = -->
<!-- SqlSelectColumn( -->
<!-- expr=SqlExtractExpression(node_id=ex_28300), -->
Expand Down Expand Up @@ -602,22 +605,25 @@ docstring:
<SqlSelectStatementNode>
<!-- description = "Read From Time Spine 'mf_time_spine'" -->
<!-- node_id = NodeId(id_str='ss_18') -->
<!-- col0 = -->
<!-- SqlSelectColumn(expr=SqlDateTruncExpression(node_id=dt_28293), column_alias='ds__day') -->
<!-- col0 = -->
<!-- SqlSelectColumn( -->
<!-- expr=SqlColumnReferenceExpression(node_id=cr_28130), -->
<!-- column_alias='ds__day', -->
<!-- ) -->
<!-- col1 = -->
<!-- SqlSelectColumn(expr=SqlDateTruncExpression(node_id=dt_28294), column_alias='ds__week') -->
<!-- SqlSelectColumn(expr=SqlDateTruncExpression(node_id=dt_28287), column_alias='ds__week') -->
<!-- col2 = -->
<!-- SqlSelectColumn( -->
<!-- expr=SqlDateTruncExpression(node_id=dt_28295), -->
<!-- expr=SqlDateTruncExpression(node_id=dt_28288), -->
<!-- column_alias='ds__month', -->
<!-- ) -->
<!-- col3 = -->
<!-- SqlSelectColumn( -->
<!-- expr=SqlDateTruncExpression(node_id=dt_28296), -->
<!-- expr=SqlDateTruncExpression(node_id=dt_28289), -->
<!-- column_alias='ds__quarter', -->
<!-- ) -->
<!-- col4 = -->
<!-- SqlSelectColumn(expr=SqlDateTruncExpression(node_id=dt_28297), column_alias='ds__year') -->
<!-- SqlSelectColumn(expr=SqlDateTruncExpression(node_id=dt_28290), column_alias='ds__year') -->
<!-- col5 = -->
<!-- SqlSelectColumn( -->
<!-- expr=SqlExtractExpression(node_id=ex_28300), -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ FROM (
FROM (
-- Read From Time Spine 'mf_time_spine'
SELECT
DATE_TRUNC('day', time_spine_src_28006.ds) AS ds__day
time_spine_src_28006.ds AS ds__day
, DATE_TRUNC('week', time_spine_src_28006.ds) AS ds__week
, DATE_TRUNC('month', time_spine_src_28006.ds) AS ds__month
, DATE_TRUNC('quarter', time_spine_src_28006.ds) AS ds__quarter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ FROM (
SELECT
DATE_TRUNC('month', time_spine_src_28006.ds) AS booking__ds__month
, DATE_TRUNC('week', time_spine_src_28006.ds) AS metric_time__week
, DATE_TRUNC('day', time_spine_src_28006.ds) AS metric_time__day
, time_spine_src_28006.ds AS metric_time__day
, subq_19.bookers AS bookers
FROM ***************************.mf_time_spine time_spine_src_28006
LEFT OUTER JOIN (
Expand All @@ -56,7 +56,7 @@ FROM (
, DATE_TRUNC('week', subq_16.ds)
) subq_19
ON
DATE_TRUNC('day', time_spine_src_28006.ds) = subq_19.metric_time__day
time_spine_src_28006.ds = subq_19.metric_time__day
) subq_23
) subq_25
GROUP BY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ FROM (
FROM (
-- Read From Time Spine 'mf_time_spine'
SELECT
DATE_TRUNC('day', time_spine_src_28006.ds) AS ds__day
time_spine_src_28006.ds AS ds__day
, DATE_TRUNC('week', time_spine_src_28006.ds) AS ds__week
, DATE_TRUNC('month', time_spine_src_28006.ds) AS ds__month
, DATE_TRUNC('quarter', time_spine_src_28006.ds) AS ds__quarter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ FROM (
LEFT OUTER JOIN
***************************.mf_time_spine subq_16
ON
DATE_TRUNC('day', time_spine_src_28006.ds) = subq_16.ds
time_spine_src_28006.ds = subq_16.ds
GROUP BY
subq_16.martian_day
) subq_18
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ FROM (
FROM (
-- Read From Time Spine 'mf_time_spine'
SELECT
DATE_TRUNC('day', time_spine_src_28006.ds) AS ds__day
time_spine_src_28006.ds AS ds__day
, DATE_TRUNC('week', time_spine_src_28006.ds) AS ds__week
, DATE_TRUNC('month', time_spine_src_28006.ds) AS ds__month
, DATE_TRUNC('quarter', time_spine_src_28006.ds) AS ds__quarter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ SELECT
subq_12.martian_day AS user__bio_added_ts__martian_day
, subq_11.martian_day AS metric_time__martian_day
, DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts) AS user__bio_added_ts__month
, DATE_TRUNC('day', time_spine_src_28006.ds) AS metric_time__day
, time_spine_src_28006.ds AS metric_time__day
FROM ***************************.dim_users users_ds_source_src_28000
CROSS JOIN
***************************.mf_time_spine time_spine_src_28006
LEFT OUTER JOIN
***************************.mf_time_spine subq_11
ON
DATE_TRUNC('day', time_spine_src_28006.ds) = subq_11.ds
time_spine_src_28006.ds = subq_11.ds
LEFT OUTER JOIN
***************************.mf_time_spine subq_12
ON
Expand All @@ -26,4 +26,4 @@ GROUP BY
subq_12.martian_day
, subq_11.martian_day
, DATE_TRUNC('month', users_ds_source_src_28000.bio_added_ts)
, DATE_TRUNC('day', time_spine_src_28006.ds)
, time_spine_src_28006.ds
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ FROM (
FROM (
-- Read From Time Spine 'mf_time_spine'
SELECT
DATE_TRUNC('day', time_spine_src_28006.ds) AS ds__day
time_spine_src_28006.ds AS ds__day
, DATE_TRUNC('week', time_spine_src_28006.ds) AS ds__week
, DATE_TRUNC('month', time_spine_src_28006.ds) AS ds__month
, DATE_TRUNC('quarter', time_spine_src_28006.ds) AS ds__quarter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ FROM ***************************.mf_time_spine time_spine_src_28006
LEFT OUTER JOIN
***************************.mf_time_spine subq_4
ON
DATE_TRUNC('day', time_spine_src_28006.ds) = subq_4.ds
time_spine_src_28006.ds = subq_4.ds
GROUP BY
subq_4.martian_day
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ FROM (
FROM (
-- Read From Time Spine 'mf_time_spine'
SELECT
DATE_TRUNC('day', time_spine_src_28006.ds) AS ds__day
time_spine_src_28006.ds AS ds__day
, DATE_TRUNC('week', time_spine_src_28006.ds) AS ds__week
, DATE_TRUNC('month', time_spine_src_28006.ds) AS ds__month
, DATE_TRUNC('quarter', time_spine_src_28006.ds) AS ds__quarter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ FROM (
FROM ***************************.fct_bookings bookings_source_src_28000
) subq_11
ON
DATE_TRUNC('day', time_spine_src_28006.ds) - INTERVAL 5 day = subq_11.booking__ds__day
time_spine_src_28006.ds - INTERVAL 5 day = subq_11.booking__ds__day
LEFT OUTER JOIN
***************************.mf_time_spine subq_15
ON
DATE_TRUNC('day', time_spine_src_28006.ds) = subq_15.ds
time_spine_src_28006.ds = subq_15.ds
GROUP BY
subq_15.martian_day
) subq_19
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ FROM (
FROM (
-- Read From Time Spine 'mf_time_spine'
SELECT
DATE_TRUNC('day', time_spine_src_28006.ds) AS ds__day
time_spine_src_28006.ds AS ds__day
, DATE_TRUNC('week', time_spine_src_28006.ds) AS ds__week
, DATE_TRUNC('month', time_spine_src_28006.ds) AS ds__month
, DATE_TRUNC('quarter', time_spine_src_28006.ds) AS ds__quarter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ FROM (
-- Join to Time Spine Dataset
-- Join to Custom Granularity Dataset
SELECT
DATE_TRUNC('day', time_spine_src_28006.ds) AS metric_time__day
time_spine_src_28006.ds AS metric_time__day
, subq_12.bookings AS bookings
, subq_16.martian_day AS metric_time__martian_day
FROM ***************************.mf_time_spine time_spine_src_28006
Expand All @@ -31,11 +31,11 @@ FROM (
FROM ***************************.fct_bookings bookings_source_src_28000
) subq_12
ON
DATE_TRUNC('day', time_spine_src_28006.ds) - INTERVAL 5 day = subq_12.metric_time__day
time_spine_src_28006.ds - INTERVAL 5 day = subq_12.metric_time__day
LEFT OUTER JOIN
***************************.mf_time_spine subq_16
ON
DATE_TRUNC('day', time_spine_src_28006.ds) = subq_16.ds
time_spine_src_28006.ds = subq_16.ds
) subq_17
WHERE metric_time__martian_day = '2020-01-01'
GROUP BY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ FROM (
FROM (
-- Read From Time Spine 'mf_time_spine'
SELECT
DATE_TRUNC('day', time_spine_src_28006.ds) AS ds__day
time_spine_src_28006.ds AS ds__day
, DATE_TRUNC('week', time_spine_src_28006.ds) AS ds__week
, DATE_TRUNC('month', time_spine_src_28006.ds) AS ds__month
, DATE_TRUNC('quarter', time_spine_src_28006.ds) AS ds__quarter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ FROM (
-- Aggregate Measures
-- Compute Metrics via Expressions
SELECT
DATE_TRUNC('day', time_spine_src_28006.ds) AS metric_time__day
time_spine_src_28006.ds AS metric_time__day
, COUNT(DISTINCT subq_17.bookers) AS every_2_days_bookers_2_days_ago
FROM ***************************.mf_time_spine time_spine_src_28006
INNER JOIN (
Expand All @@ -32,8 +32,8 @@ FROM (
)
) subq_17
ON
DATE_TRUNC('day', time_spine_src_28006.ds) - INTERVAL 2 day = subq_17.metric_time__day
WHERE DATE_TRUNC('day', time_spine_src_28006.ds) BETWEEN '2019-12-19' AND '2020-01-02'
time_spine_src_28006.ds - INTERVAL 2 day = subq_17.metric_time__day
WHERE time_spine_src_28006.ds BETWEEN '2019-12-19' AND '2020-01-02'
GROUP BY
DATE_TRUNC('day', time_spine_src_28006.ds)
time_spine_src_28006.ds
) subq_25
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ FROM (
FROM (
-- Read From Time Spine 'mf_time_spine'
SELECT
DATE_TRUNC('day', time_spine_src_16006.ds) AS ds__day
time_spine_src_16006.ds AS ds__day
, DATE_TRUNC('week', time_spine_src_16006.ds) AS ds__week
, DATE_TRUNC('month', time_spine_src_16006.ds) AS ds__month
, DATE_TRUNC('quarter', time_spine_src_16006.ds) AS ds__quarter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ FROM (
FROM (
-- Read From Time Spine 'mf_time_spine'
SELECT
DATE_TRUNC('day', time_spine_src_28006.ds) AS ds__day
time_spine_src_28006.ds AS ds__day
, DATE_TRUNC('week', time_spine_src_28006.ds) AS ds__week
, DATE_TRUNC('month', time_spine_src_28006.ds) AS ds__month
, DATE_TRUNC('quarter', time_spine_src_28006.ds) AS ds__quarter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ FROM (
-- Aggregate Measures
-- Compute Metrics via Expressions
SELECT
DATE_TRUNC('day', time_spine_src_28006.ds) AS metric_time__day
time_spine_src_28006.ds AS metric_time__day
, SUM(subq_21.bookings) AS bookings_at_start_of_month
FROM ***************************.mf_time_spine time_spine_src_28006
INNER JOIN (
Expand All @@ -48,9 +48,9 @@ FROM (
FROM ***************************.fct_bookings bookings_source_src_28000
) subq_21
ON
DATE_TRUNC('month', DATE_TRUNC('day', time_spine_src_28006.ds)) = subq_21.metric_time__day
DATE_TRUNC('month', time_spine_src_28006.ds) = subq_21.metric_time__day
GROUP BY
DATE_TRUNC('day', time_spine_src_28006.ds)
time_spine_src_28006.ds
) subq_28
ON
subq_19.metric_time__day = subq_28.metric_time__day
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ FROM (
FROM (
-- Read From Time Spine 'mf_time_spine'
SELECT
DATE_TRUNC('day', time_spine_src_28006.ds) AS ds__day
time_spine_src_28006.ds AS ds__day
, DATE_TRUNC('week', time_spine_src_28006.ds) AS ds__week
, DATE_TRUNC('month', time_spine_src_28006.ds) AS ds__month
, DATE_TRUNC('quarter', time_spine_src_28006.ds) AS ds__quarter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ FROM (
FROM ***************************.fct_bookings bookings_source_src_28000
) subq_21
ON
DATE_TRUNC('month', DATE_TRUNC('day', time_spine_src_28006.ds)) = subq_21.metric_time__day
WHERE DATE_TRUNC('week', time_spine_src_28006.ds) = DATE_TRUNC('day', time_spine_src_28006.ds)
DATE_TRUNC('month', time_spine_src_28006.ds) = subq_21.metric_time__day
WHERE DATE_TRUNC('week', time_spine_src_28006.ds) = time_spine_src_28006.ds
GROUP BY
DATE_TRUNC('week', time_spine_src_28006.ds)
) subq_28
Expand Down
Loading

0 comments on commit 05af31e

Please sign in to comment.