diff --git a/metricflow/test/dataflow/optimizer/source_scan/test_source_scan_optimizer.py b/metricflow/test/dataflow/optimizer/source_scan/test_source_scan_optimizer.py index 78d557e2b5..07f4c76663 100644 --- a/metricflow/test/dataflow/optimizer/source_scan/test_source_scan_optimizer.py +++ b/metricflow/test/dataflow/optimizer/source_scan/test_source_scan_optimizer.py @@ -32,11 +32,14 @@ from metricflow.dataset.data_source_adapter import DataSourceDataSet from metricflow.dataset.dataset import DataSet from metricflow.specs import ( - MetricFlowQuerySpec, - MetricSpec, DimensionSpec, IdentifierReference, + LinkableSpecSet, + MetricFlowQuerySpec, + MetricSpec, + SpecWhereClauseConstraint, ) +from metricflow.sql.sql_bind_parameters import SqlBindParameters from metricflow.test.dataflow_plan_to_svg import display_graph_if_requested from metricflow.test.fixtures.setup_fixtures import MetricFlowTestSessionState from metricflow.test.plan_utils import assert_plan_snapshot_text_equal @@ -231,7 +234,25 @@ def test_constrained_metric_not_combined( # noqa: D mf_test_session_state=mf_test_session_state, dataflow_plan_builder=dataflow_plan_builder, query_spec=MetricFlowQuerySpec( - metric_specs=(MetricSpec(element_name="booking_value"), MetricSpec(element_name="instant_booking_value")), + metric_specs=( + MetricSpec(element_name="booking_value"), + MetricSpec( + element_name="instant_booking_value", + constraint=SpecWhereClauseConstraint( + where_condition="is_instant", + linkable_names=("is_instant",), + linkable_spec_set=LinkableSpecSet( + dimension_specs=( + DimensionSpec( + element_name="is_instant", + identifier_links=(), + ), + ) + ), + execution_parameters=SqlBindParameters(), + ), + ), + ), dimension_specs=(DataSet.metric_time_dimension_spec(TimeGranularity.DAY),), ), expected_num_sources_in_unoptimized=2, diff --git a/metricflow/test/plan_conversion/test_dataflow_to_sql_plan.py b/metricflow/test/plan_conversion/test_dataflow_to_sql_plan.py index 75f67964b2..e5ace60d91 100644 --- a/metricflow/test/plan_conversion/test_dataflow_to_sql_plan.py +++ b/metricflow/test/plan_conversion/test_dataflow_to_sql_plan.py @@ -1434,7 +1434,24 @@ def test_join_to_scd_dimension( """Tests conversion of a plan using a dimension with a validity window inside a measure constraint""" dataflow_plan = scd_dataflow_plan_builder.build_plan( MetricFlowQuerySpec( - metric_specs=(MetricSpec(element_name="family_bookings"),), + metric_specs=( + MetricSpec( + element_name="family_bookings", + constraint=SpecWhereClauseConstraint( + where_condition="listing__capacity > 2", + linkable_names=("listing__capacity",), + linkable_spec_set=LinkableSpecSet( + dimension_specs=( + DimensionSpec( + element_name="capacity", + identifier_links=(IdentifierReference(element_name="listing"),), + ), + ), + ), + execution_parameters=SqlBindParameters(), + ), + ), + ), time_dimension_specs=(MTD_SPEC_DAY,), ), ) diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfp_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfp_0.xml index 68c3333201..c96c9eae3f 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfp_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfp_0.xml @@ -50,11 +50,21 @@ - - - - - + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfpo_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfpo_0.xml index 3b8de5c7d4..e66ccd9e23 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfpo_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfpo_0.xml @@ -50,11 +50,21 @@ - - - - - + + + + + + + + + + + + + + +