Skip to content

Commit

Permalink
Sort specs in FilterElementsNode to ensure consistent snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Jul 27, 2024
1 parent 1669d86 commit 398c5dc
Show file tree
Hide file tree
Showing 239 changed files with 634 additions and 633 deletions.
3 changes: 2 additions & 1 deletion metricflow/dataflow/nodes/filter_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def description(self) -> str: # noqa: D102
if self.replace_description:
return self.replace_description

return f"Pass Only Elements: {mf_pformat([x.qualified_name for x in self.include_specs.all_specs])}"
# Sort specs to ensure consistent snapshots.
return f"Pass Only Elements: {mf_pformat(sorted(x.qualified_name for x in self.include_specs.all_specs))}"

@property
def displayed_properties(self) -> Sequence[DisplayedProperty]: # noqa: D102
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- description = 'Write to DataTable' -->
<!-- node_id = NodeId(id_str='wrd_0') -->
<FilterElementsNode>
<!-- description = "Pass Only Elements: ['bookings', 'booking_value']" -->
<!-- description = "Pass Only Elements: ['booking_value', 'bookings']" -->
<!-- node_id = NodeId(id_str='pfe_2') -->
<!-- include_spec = MeasureSpec(element_name='bookings') -->
<!-- include_spec = MeasureSpec(element_name='booking_value') -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ FROM (
subq_2.metric_time__day
, subq_2.visits
FROM (
-- Pass Only Elements: ['visits', 'metric_time__day']
-- Pass Only Elements: ['metric_time__day', 'visits']
SELECT
subq_1.metric_time__day
, subq_1.visits
Expand Down Expand Up @@ -165,7 +165,7 @@ FROM (
, subq_10.mf_internal_uuid AS mf_internal_uuid
, subq_10.buys AS buys
FROM (
-- Pass Only Elements: ['visits', 'ds__day', 'metric_time__day', 'user']
-- Pass Only Elements: ['ds__day', 'metric_time__day', 'user', 'visits']
SELECT
subq_6.ds__day
, subq_6.metric_time__day
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ FROM (
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
-- Pass Only Elements: ['visits', 'metric_time__day']
-- Pass Only Elements: ['metric_time__day', 'visits']
SELECT
DATE_TRUNC('day', ds) AS metric_time__day
, 1 AS visits
Expand Down Expand Up @@ -74,7 +74,7 @@ FROM (
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
-- Pass Only Elements: ['visits', 'ds__day', 'metric_time__day', 'user']
-- Pass Only Elements: ['ds__day', 'metric_time__day', 'user', 'visits']
SELECT
DATE_TRUNC('day', ds) AS ds__day
, DATE_TRUNC('day', ds) AS metric_time__day
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ FROM (
, subq_2.visit__referrer_id
, subq_2.visits
FROM (
-- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day']
-- Pass Only Elements: ['metric_time__day', 'visit__referrer_id', 'visits']
SELECT
subq_1.metric_time__day
, subq_1.visit__referrer_id
Expand Down Expand Up @@ -122,7 +122,7 @@ FROM (
, subq_13.visit__referrer_id
, SUM(subq_13.buys) AS buys
FROM (
-- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day']
-- Pass Only Elements: ['buys', 'metric_time__day', 'visit__referrer_id']
SELECT
subq_12.metric_time__day
, subq_12.visit__referrer_id
Expand Down Expand Up @@ -182,7 +182,7 @@ FROM (
, subq_10.mf_internal_uuid AS mf_internal_uuid
, subq_10.buys AS buys
FROM (
-- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user']
-- Pass Only Elements: ['ds__day', 'metric_time__day', 'user', 'visit__referrer_id', 'visits']
SELECT
subq_6.ds__day
, subq_6.metric_time__day
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ FROM (
, MAX(subq_30.buys) AS buys
FROM (
-- Constrain Output with WHERE
-- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day']
-- Pass Only Elements: ['metric_time__day', 'visit__referrer_id', 'visits']
-- Aggregate Measures
SELECT
metric_time__day
Expand All @@ -34,7 +34,7 @@ FROM (
) subq_20
FULL OUTER JOIN (
-- Find conversions for user within the range of INF
-- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day']
-- Pass Only Elements: ['buys', 'metric_time__day', 'visit__referrer_id']
-- Aggregate Measures
SELECT
metric_time__day
Expand Down Expand Up @@ -88,7 +88,7 @@ FROM (
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
-- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user']
-- Pass Only Elements: ['ds__day', 'metric_time__day', 'user', 'visit__referrer_id', 'visits']
SELECT
DATE_TRUNC('day', ds) AS ds__day
, DATE_TRUNC('day', ds) AS metric_time__day
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ FROM (
subq_3.visit__referrer_id
, subq_3.visits
FROM (
-- Pass Only Elements: ['visits', 'visit__referrer_id']
-- Pass Only Elements: ['visit__referrer_id', 'visits']
SELECT
subq_2.visit__referrer_id
, subq_2.visits
Expand Down Expand Up @@ -211,7 +211,7 @@ FROM (
, subq_12.mf_internal_uuid AS mf_internal_uuid
, subq_12.buys AS buys
FROM (
-- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'user']
-- Pass Only Elements: ['ds__day', 'user', 'visit__referrer_id', 'visits']
SELECT
subq_8.ds__day
, subq_8.user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ FROM (
FROM (
-- Constrain Output with WHERE
-- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00]
-- Pass Only Elements: ['visits', 'visit__referrer_id']
-- Pass Only Elements: ['visit__referrer_id', 'visits']
-- Aggregate Measures
SELECT
visit__referrer_id
Expand Down Expand Up @@ -81,7 +81,7 @@ FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
-- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00]
-- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'user']
-- Pass Only Elements: ['ds__day', 'user', 'visit__referrer_id', 'visits']
SELECT
DATE_TRUNC('day', ds) AS ds__day
, user_id AS user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ FROM (
subq_2.metric_time__day
, subq_2.visits
FROM (
-- Pass Only Elements: ['visits', 'metric_time__day']
-- Pass Only Elements: ['metric_time__day', 'visits']
SELECT
subq_1.metric_time__day
, subq_1.visits
Expand Down Expand Up @@ -165,7 +165,7 @@ FROM (
, subq_10.mf_internal_uuid AS mf_internal_uuid
, subq_10.buys AS buys
FROM (
-- Pass Only Elements: ['visits', 'ds__day', 'metric_time__day', 'user']
-- Pass Only Elements: ['ds__day', 'metric_time__day', 'user', 'visits']
SELECT
subq_6.ds__day
, subq_6.metric_time__day
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ FROM (
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
-- Pass Only Elements: ['visits', 'metric_time__day']
-- Pass Only Elements: ['metric_time__day', 'visits']
SELECT
DATE_TRUNC('day', ds) AS metric_time__day
, 1 AS visits
Expand Down Expand Up @@ -74,7 +74,7 @@ FROM (
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
-- Pass Only Elements: ['visits', 'ds__day', 'metric_time__day', 'user']
-- Pass Only Elements: ['ds__day', 'metric_time__day', 'user', 'visits']
SELECT
DATE_TRUNC('day', ds) AS ds__day
, DATE_TRUNC('day', ds) AS metric_time__day
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ FROM (
, subq_3.visit__referrer_id
, subq_3.visits
FROM (
-- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day']
-- Pass Only Elements: ['metric_time__day', 'visit__referrer_id', 'visits']
SELECT
subq_2.metric_time__day
, subq_2.visit__referrer_id
Expand Down Expand Up @@ -168,7 +168,7 @@ FROM (
, subq_15.visit__referrer_id
, SUM(subq_15.buys) AS buys
FROM (
-- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day']
-- Pass Only Elements: ['buys', 'metric_time__day', 'visit__referrer_id']
SELECT
subq_14.metric_time__day
, subq_14.visit__referrer_id
Expand Down Expand Up @@ -228,7 +228,7 @@ FROM (
, subq_12.mf_internal_uuid AS mf_internal_uuid
, subq_12.buys AS buys
FROM (
-- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user']
-- Pass Only Elements: ['ds__day', 'metric_time__day', 'user', 'visit__referrer_id', 'visits']
SELECT
subq_8.ds__day
, subq_8.metric_time__day
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ FROM (
FROM (
-- Constrain Output with WHERE
-- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00]
-- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day']
-- Pass Only Elements: ['metric_time__day', 'visit__referrer_id', 'visits']
-- Aggregate Measures
SELECT
metric_time__day
Expand All @@ -39,7 +39,7 @@ FROM (
) subq_23
FULL OUTER JOIN (
-- Find conversions for user within the range of 7 day
-- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day']
-- Pass Only Elements: ['buys', 'metric_time__day', 'visit__referrer_id']
-- Aggregate Measures
SELECT
metric_time__day
Expand Down Expand Up @@ -94,7 +94,7 @@ FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
-- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00]
-- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user']
-- Pass Only Elements: ['ds__day', 'metric_time__day', 'user', 'visit__referrer_id', 'visits']
SELECT
DATE_TRUNC('day', ds) AS ds__day
, DATE_TRUNC('day', ds) AS metric_time__day
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ FROM (
, subq_9.mf_internal_uuid AS mf_internal_uuid
, subq_9.buys AS buys
FROM (
-- Pass Only Elements: ['visits', 'ds__day', 'user']
-- Pass Only Elements: ['ds__day', 'user', 'visits']
SELECT
subq_5.ds__day
, subq_5.user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ CROSS JOIN (
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
-- Pass Only Elements: ['visits', 'ds__day', 'user']
-- Pass Only Elements: ['ds__day', 'user', 'visits']
SELECT
DATE_TRUNC('day', ds) AS ds__day
, user_id AS user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ FROM (
subq_2.metric_time__day
, SUM(subq_2.visits) AS visits
FROM (
-- Pass Only Elements: ['visits', 'metric_time__day']
-- Pass Only Elements: ['metric_time__day', 'visits']
SELECT
subq_1.metric_time__day
, subq_1.visits
Expand Down Expand Up @@ -183,7 +183,7 @@ FROM (
, subq_12.mf_internal_uuid AS mf_internal_uuid
, subq_12.buys AS buys
FROM (
-- Pass Only Elements: ['visits', 'ds__day', 'metric_time__day', 'user']
-- Pass Only Elements: ['ds__day', 'metric_time__day', 'user', 'visits']
SELECT
subq_8.ds__day
, subq_8.metric_time__day
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ FROM (
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
-- Pass Only Elements: ['visits', 'metric_time__day']
-- Pass Only Elements: ['metric_time__day', 'visits']
SELECT
DATE_TRUNC('day', ds) AS metric_time__day
, 1 AS visits
Expand Down Expand Up @@ -87,7 +87,7 @@ FROM (
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
-- Pass Only Elements: ['visits', 'ds__day', 'metric_time__day', 'user']
-- Pass Only Elements: ['ds__day', 'metric_time__day', 'user', 'visits']
SELECT
DATE_TRUNC('day', ds) AS ds__day
, DATE_TRUNC('day', ds) AS metric_time__day
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ FROM (
subq_2.visit__referrer_id
, SUM(subq_2.visits) AS visits
FROM (
-- Pass Only Elements: ['visits', 'visit__referrer_id']
-- Pass Only Elements: ['visit__referrer_id', 'visits']
SELECT
subq_1.visit__referrer_id
, subq_1.visits
Expand Down Expand Up @@ -158,7 +158,7 @@ FROM (
, subq_9.mf_internal_uuid AS mf_internal_uuid
, subq_9.buys AS buys
FROM (
-- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'user']
-- Pass Only Elements: ['ds__day', 'user', 'visit__referrer_id', 'visits']
SELECT
subq_5.ds__day
, subq_5.user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ FROM (
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
-- Pass Only Elements: ['visits', 'visit__referrer_id']
-- Pass Only Elements: ['visit__referrer_id', 'visits']
SELECT
referrer_id AS visit__referrer_id
, 1 AS visits
Expand Down Expand Up @@ -72,7 +72,7 @@ FROM (
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
-- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'user']
-- Pass Only Elements: ['ds__day', 'user', 'visit__referrer_id', 'visits']
SELECT
DATE_TRUNC('day', ds) AS ds__day
, user_id AS user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ FROM (
, subq_2.visit__referrer_id
, SUM(subq_2.visits) AS visits
FROM (
-- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day']
-- Pass Only Elements: ['metric_time__day', 'visit__referrer_id', 'visits']
SELECT
subq_1.metric_time__day
, subq_1.visit__referrer_id
Expand Down Expand Up @@ -114,7 +114,7 @@ FROM (
, subq_12.visit__referrer_id
, SUM(subq_12.buys) AS buys
FROM (
-- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day']
-- Pass Only Elements: ['buys', 'metric_time__day', 'visit__referrer_id']
SELECT
subq_11.metric_time__day
, subq_11.visit__referrer_id
Expand Down Expand Up @@ -189,7 +189,7 @@ FROM (
, subq_9.mf_internal_uuid AS mf_internal_uuid
, subq_9.buys AS buys
FROM (
-- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user', 'session']
-- Pass Only Elements: ['ds__day', 'metric_time__day', 'session', 'user', 'visit__referrer_id', 'visits']
SELECT
subq_5.ds__day
, subq_5.metric_time__day
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ FROM (
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
-- Pass Only Elements: ['visits', 'visit__referrer_id', 'metric_time__day']
-- Pass Only Elements: ['metric_time__day', 'visit__referrer_id', 'visits']
SELECT
DATE_TRUNC('day', ds) AS metric_time__day
, referrer_id AS visit__referrer_id
Expand All @@ -32,7 +32,7 @@ FROM (
) subq_18
FULL OUTER JOIN (
-- Find conversions for user within the range of 7 day
-- Pass Only Elements: ['buys', 'visit__referrer_id', 'metric_time__day']
-- Pass Only Elements: ['buys', 'metric_time__day', 'visit__referrer_id']
-- Aggregate Measures
SELECT
metric_time__day
Expand Down Expand Up @@ -100,7 +100,7 @@ FROM (
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
-- Pass Only Elements: ['visits', 'visit__referrer_id', 'ds__day', 'metric_time__day', 'user', 'session']
-- Pass Only Elements: ['ds__day', 'metric_time__day', 'session', 'user', 'visit__referrer_id', 'visits']
SELECT
DATE_TRUNC('day', ds) AS ds__day
, DATE_TRUNC('day', ds) AS metric_time__day
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ FROM (
, subq_9.mf_internal_uuid AS mf_internal_uuid
, subq_9.buys AS buys
FROM (
-- Pass Only Elements: ['visits', 'ds__day', 'user']
-- Pass Only Elements: ['ds__day', 'user', 'visits']
SELECT
subq_5.ds__day
, subq_5.user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ CROSS JOIN (
FROM (
-- Read Elements From Semantic Model 'visits_source'
-- Metric Time Dimension 'ds'
-- Pass Only Elements: ['visits', 'ds__day', 'user']
-- Pass Only Elements: ['ds__day', 'user', 'visits']
SELECT
DATE_TRUNC('day', ds) AS ds__day
, user_id AS user
Expand Down
Loading

0 comments on commit 398c5dc

Please sign in to comment.