Skip to content

Commit

Permalink
Output tests for SCD without metric_time
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Jan 24, 2025
1 parent 2609a0a commit 73787e5
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests_metricflow/integration/query_output/test_query_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,54 @@ def test_scd_with_coarser_grain( # noqa: D103
snapshot_str=query_result.result_df.text_format(),
sql_engine=sql_client.sql_engine_type,
)


@pytest.mark.sql_engine_snapshot
@pytest.mark.duckdb_only
def test_scd_group_by_without_metric_time( # noqa: D103
request: FixtureRequest,
mf_test_configuration: MetricFlowTestConfiguration,
sql_client: SqlClient,
scd_it_helpers: IntegrationTestHelpers,
) -> None:
query_result = scd_it_helpers.mf_engine.query(
MetricFlowQueryRequest.create_with_random_request_id(
metrics=(MetricParameter(name="family_bookings"),),
group_by_names=["listing__capacity"],
order_by_names=["listing__capacity"],
)
)
assert query_result.result_df is not None, "Unexpected empty result."

assert_str_snapshot_equal(
request=request,
mf_test_configuration=mf_test_configuration,
snapshot_id="query_output",
snapshot_str=query_result.result_df.text_format(),
sql_engine=sql_client.sql_engine_type,
)


@pytest.mark.sql_engine_snapshot
@pytest.mark.duckdb_only
def test_scd_filter_without_metric_time( # noqa: D103
request: FixtureRequest,
mf_test_configuration: MetricFlowTestConfiguration,
sql_client: SqlClient,
scd_it_helpers: IntegrationTestHelpers,
) -> None:
query_result = scd_it_helpers.mf_engine.query(
MetricFlowQueryRequest.create_with_random_request_id(
metrics=(MetricParameter(name="family_bookings"),),
where_constraints=("{{ Dimension('listing__capacity') }} > 2",),
)
)
assert query_result.result_df is not None, "Unexpected empty result."

assert_str_snapshot_equal(
request=request,
mf_test_configuration=mf_test_configuration,
snapshot_id="query_output",
snapshot_str=query_result.result_df.text_format(),
sql_engine=sql_client.sql_engine_type,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
test_name: test_scd_filter_without_metric_time
test_filename: test_query_output.py
---
family_bookings
-----------------
9
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
test_name: test_scd_group_by_without_metric_time
test_filename: test_query_output.py
---
listing__capacity family_bookings
------------------- -----------------
3 2
4 5
5 2

0 comments on commit 73787e5

Please sign in to comment.