Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamDee committed Jan 10, 2023
1 parent 2a22ca6 commit 91f9f08
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,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
Expand Down Expand Up @@ -235,7 +238,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,
Expand Down
19 changes: 18 additions & 1 deletion metricflow/test/plan_conversion/test_dataflow_to_sql_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -1633,7 +1633,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,),
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,23 @@
<ComputeMetricsNode>
<!-- description = Compute Metrics via Expressions -->
<!-- node_id = cm_1 -->
<!-- metric_spec = -->
<!-- {'class': 'MetricSpec', -->
<!-- 'element_name': 'instant_booking_value', -->
<!-- 'constraint': None, -->
<!-- 'alias': None, -->
<!-- 'offset_window': None, -->
<!-- 'offset_to_grain': None} -->
<!-- metric_spec = -->
<!-- {'class': 'MetricSpec', -->
<!-- 'element_name': 'instant_booking_value', -->
<!-- 'constraint': {'class': 'SpecWhereClauseConstraint', -->
<!-- 'where_condition': 'is_instant', -->
<!-- 'linkable_names': ('is_instant',), -->
<!-- 'linkable_spec_set': {'class': 'LinkableSpecSet', -->
<!-- 'dimension_specs': ({'class': 'DimensionSpec', -->
<!-- 'element_name': 'is_instant', -->
<!-- 'identifier_links': ()},), -->
<!-- 'time_dimension_specs': (), -->
<!-- 'identifier_specs': ()}, -->
<!-- 'execution_parameters': {'class': 'SqlBindParameters', -->
<!-- 'param_items': ()}}, -->
<!-- 'alias': None, -->
<!-- 'offset_window': None, -->
<!-- 'offset_to_grain': None} -->
<AggregateMeasuresNode>
<!-- description = Aggregate Measures -->
<!-- node_id = am_1 -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,23 @@
<ComputeMetricsNode>
<!-- description = Compute Metrics via Expressions -->
<!-- node_id = cm_3 -->
<!-- metric_spec = -->
<!-- {'class': 'MetricSpec', -->
<!-- 'element_name': 'instant_booking_value', -->
<!-- 'constraint': None, -->
<!-- 'alias': None, -->
<!-- 'offset_window': None, -->
<!-- 'offset_to_grain': None} -->
<!-- metric_spec = -->
<!-- {'class': 'MetricSpec', -->
<!-- 'element_name': 'instant_booking_value', -->
<!-- 'constraint': {'class': 'SpecWhereClauseConstraint', -->
<!-- 'where_condition': 'is_instant', -->
<!-- 'linkable_names': ('is_instant',), -->
<!-- 'linkable_spec_set': {'class': 'LinkableSpecSet', -->
<!-- 'dimension_specs': ({'class': 'DimensionSpec', -->
<!-- 'element_name': 'is_instant', -->
<!-- 'identifier_links': ()},), -->
<!-- 'time_dimension_specs': (), -->
<!-- 'identifier_specs': ()}, -->
<!-- 'execution_parameters': {'class': 'SqlBindParameters', -->
<!-- 'param_items': ()}}, -->
<!-- 'alias': None, -->
<!-- 'offset_window': None, -->
<!-- 'offset_to_grain': None} -->
<AggregateMeasuresNode>
<!-- description = Aggregate Measures -->
<!-- node_id = am_3 -->
Expand Down

0 comments on commit 91f9f08

Please sign in to comment.