Skip to content

Commit

Permalink
Add rendering tests for metric filters using local entity prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed May 8, 2024
1 parent 2cc544a commit 247e205
Show file tree
Hide file tree
Showing 5 changed files with 1,032 additions and 0 deletions.
80 changes: 80 additions & 0 deletions tests_metricflow/query_rendering/test_metric_filter_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,83 @@ def test_metric_filtered_by_itself(
sql_client=sql_client,
node=dataflow_plan.sink_output_nodes[0].parent_node,
)


@pytest.mark.sql_engine_snapshot
def test_group_by_has_local_entity_prefix(
request: FixtureRequest,
mf_test_configuration: MetricFlowTestConfiguration,
dataflow_plan_builder: DataflowPlanBuilder,
sql_client: SqlClient,
dataflow_to_sql_converter: DataflowToSqlQueryPlanConverter,
query_parser: MetricFlowQueryParser,
) -> None:
query_spec = query_parser.parse_and_validate_query(
metric_names=("listings",),
where_constraint=PydanticWhereFilter(
where_sql_template="{{ Metric('average_booking_value', ['listing__user']) }} > 1",
),
)
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,
)


@pytest.mark.sql_engine_snapshot
def test_group_by_has_local_entity_prefix2(
request: FixtureRequest,
mf_test_configuration: MetricFlowTestConfiguration,
dataflow_plan_builder: DataflowPlanBuilder,
sql_client: SqlClient,
dataflow_to_sql_converter: DataflowToSqlQueryPlanConverter,
query_parser: MetricFlowQueryParser,
) -> None:
query_spec = query_parser.parse_and_validate_query(
metric_names=("listings",),
where_constraint=PydanticWhereFilter(
where_sql_template="{{ Metric('views', ['view__listing']) }} > 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,
)


# booking_value_per_view by listing
# visit_buy_conversion_rate by user
# Then get some ACTUAL MULTIHOP OPTIONS!!!


@pytest.mark.sql_engine_snapshot
def test_test(
request: FixtureRequest,
mf_test_configuration: MetricFlowTestConfiguration,
dataflow_plan_builder: DataflowPlanBuilder,
sql_client: SqlClient,
dataflow_to_sql_converter: DataflowToSqlQueryPlanConverter,
query_parser: MetricFlowQueryParser,
) -> None:
query_spec = query_parser.parse_and_validate_query(
metric_names=("average_booking_value",), group_by_names=("listing__user",)
)
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,
)
Loading

0 comments on commit 247e205

Please sign in to comment.