Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamDee committed Oct 10, 2024
1 parent 93a6ef2 commit a3f1693
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ metric:
description: "average booking value metric"
type: simple
type_params:
measure: average_booking_value
measure:
name: average_booking_value
filter: "average_booking_value > 10"

---
metric:
name: "instant_bookings"
Expand Down Expand Up @@ -629,6 +632,16 @@ metric:
fill_nulls_with: 0
time_granularity: week
---
metric:
name: instant_bookings_with_measure_filter
description: simple metric joining to time spine with measure filter
type: simple
type_params:
measure:
name: bookings
join_to_timespine: true
filter: "{{ Dimension('booking__is_instant') }}"
---
metric:
name: every_two_days_bookers_fill_nulls_with_0
description: cumulative metric filling 0
Expand Down
31 changes: 31 additions & 0 deletions tests_metricflow/query_rendering/test_time_spine_join_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,34 @@ def test_join_to_time_spine_with_queried_time_constraint(
dataflow_plan_builder=dataflow_plan_builder,
query_spec=query_spec,
)


@pytest.mark.sql_engine_snapshot
def test_join_to_time_spine_with_input_measure_constraint(
request: FixtureRequest,
mf_test_configuration: MetricFlowTestConfiguration,
dataflow_plan_builder: DataflowPlanBuilder,
dataflow_to_sql_converter: DataflowToSqlQueryPlanConverter,
sql_client: SqlClient,
query_parser: MetricFlowQueryParser,
) -> None:
"""Check filter hierarchy.
Ensure that the measure filter 'booking__is_instant' doesn't get applied again post-aggregation.
"""
query_spec = query_parser.parse_and_validate_query(
metric_names=("instant_bookings_with_measure_filter",),
group_by_names=("metric_time__day", "booking__is_instant"),
where_constraints=[
PydanticWhereFilter(where_sql_template="{{ TimeDimension('metric_time', 'day') }} > '2020-01-01'")
],
).query_spec

render_and_check(
request=request,
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
dataflow_plan_builder=dataflow_plan_builder,
query_spec=query_spec,
)

0 comments on commit a3f1693

Please sign in to comment.