Skip to content

Commit

Permalink
Add separate multi-hop test without explicity entity link
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Apr 23, 2024
1 parent 448c5dd commit 0e6830a
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions tests/query_rendering/test_metric_filter_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,15 @@ def test_metric_filtered_by_itself(


@pytest.mark.sql_engine_snapshot
def test_query_with_simple_metric_in_where_filter_multi_hop(
def test_multi_hop_with_explicit_entity_link(
request: FixtureRequest,
mf_test_configuration: MetricFlowTestConfiguration,
dataflow_plan_builder: DataflowPlanBuilder,
sql_client: SqlClient,
dataflow_to_sql_converter: DataflowToSqlQueryPlanConverter,
query_parser: MetricFlowQueryParser,
) -> None:
"""Tests a query with a simple metric in the query-level where filter."""
"""Tests a metric filter that requires multiple join hops and explicitly states the entity link."""
query_spec = query_parser.parse_and_validate_query(
metric_names=("listings",),
where_constraint=PydanticWhereFilter(
Expand All @@ -281,3 +281,33 @@ def test_query_with_simple_metric_in_where_filter_multi_hop(
sql_client=sql_client,
node=dataflow_plan.sink_output_nodes[0].parent_node,
)


@pytest.mark.sql_engine_snapshot
def test_multi_hop_without_explicit_entity_link(
request: FixtureRequest,
mf_test_configuration: MetricFlowTestConfiguration,
dataflow_plan_builder: DataflowPlanBuilder,
sql_client: SqlClient,
dataflow_to_sql_converter: DataflowToSqlQueryPlanConverter,
query_parser: MetricFlowQueryParser,
) -> None:
"""Tests a metric filter that requires multiple join hops and does not state the entity link.
Should return the same SQL as if the entity link was stated (group by resolution determines the entity link).
"""
query_spec = query_parser.parse_and_validate_query(
metric_names=("listings",),
where_constraint=PydanticWhereFilter(
where_sql_template="{{ Metric('instant_bookings', ['company']) }} > 2",
),
)
dataflow_plan = dataflow_plan_builder.build_plan(query_spec)

convert_and_check(
request=request,
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.sink_output_nodes[0].parent_node,
)

0 comments on commit 0e6830a

Please sign in to comment.