From bc04559ca29a02cc9f120baa9edbdc5c3be25558 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Mon, 4 Nov 2024 19:57:23 -0800 Subject: [PATCH] Add query output test --- .../query_output/test_fill_nulls_with_0.py | 25 +++++++++++++++++++ ...custom_grain_in_group_by__query_output.txt | 17 +++++++++++++ ...custom_grain_in_group_by__query_output.txt | 17 +++++++++++++ ...custom_grain_in_group_by__query_output.txt | 17 +++++++++++++ ...custom_grain_in_group_by__query_output.txt | 17 +++++++++++++ ...custom_grain_in_group_by__query_output.txt | 17 +++++++++++++ ...custom_grain_in_group_by__query_output.txt | 17 +++++++++++++ ...custom_grain_in_group_by__query_output.txt | 17 +++++++++++++ 8 files changed, 144 insertions(+) create mode 100644 tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/BigQuery/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt create mode 100644 tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Databricks/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt create mode 100644 tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/DuckDB/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt create mode 100644 tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Postgres/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt create mode 100644 tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Redshift/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt create mode 100644 tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Snowflake/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt create mode 100644 tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Trino/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt diff --git a/tests_metricflow/integration/query_output/test_fill_nulls_with_0.py b/tests_metricflow/integration/query_output/test_fill_nulls_with_0.py index 3d6401884f..b2e22ce13d 100644 --- a/tests_metricflow/integration/query_output/test_fill_nulls_with_0.py +++ b/tests_metricflow/integration/query_output/test_fill_nulls_with_0.py @@ -270,3 +270,28 @@ def test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metri snapshot_str=query_result.result_df.text_format(), sql_engine=sql_client.sql_engine_type, ) + + +@pytest.mark.sql_engine_snapshot +def test_join_to_time_spine_with_custom_grain_in_group_by( # noqa: D103 + request: FixtureRequest, + mf_test_configuration: MetricFlowTestConfiguration, + sql_client: SqlClient, + it_helpers: IntegrationTestHelpers, +) -> None: + query_result = it_helpers.mf_engine.query( + MetricFlowQueryRequest.create_with_random_request_id( + metric_names=["bookings_join_to_time_spine"], + group_by_names=["booking__ds__martian_day"], + order_by_names=["booking__ds__martian_day"], + ) + ) + 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, + ) diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/BigQuery/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt b/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/BigQuery/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt new file mode 100644 index 0000000000..82824f664e --- /dev/null +++ b/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/BigQuery/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt @@ -0,0 +1,17 @@ +booking__ds__martian_day bookings_join_to_time_spine +-------------------------- ----------------------------- +2020-01-01T00:00:00 None +2020-01-02T00:00:00 None +2020-01-03T00:00:00 None +2020-01-04T00:00:00 None +2020-01-05T00:00:00 None +2020-01-06T00:00:00 None +2020-01-07T00:00:00 None +2020-01-08T00:00:00 46 +2020-01-09T00:00:00 None +2020-01-10T00:00:00 None +2020-01-11T00:00:00 None +2020-01-12T00:00:00 None +2020-01-13T00:00:00 None +2020-01-14T00:00:00 None +2020-01-15T00:00:00 None diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Databricks/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt b/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Databricks/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt new file mode 100644 index 0000000000..82824f664e --- /dev/null +++ b/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Databricks/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt @@ -0,0 +1,17 @@ +booking__ds__martian_day bookings_join_to_time_spine +-------------------------- ----------------------------- +2020-01-01T00:00:00 None +2020-01-02T00:00:00 None +2020-01-03T00:00:00 None +2020-01-04T00:00:00 None +2020-01-05T00:00:00 None +2020-01-06T00:00:00 None +2020-01-07T00:00:00 None +2020-01-08T00:00:00 46 +2020-01-09T00:00:00 None +2020-01-10T00:00:00 None +2020-01-11T00:00:00 None +2020-01-12T00:00:00 None +2020-01-13T00:00:00 None +2020-01-14T00:00:00 None +2020-01-15T00:00:00 None diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/DuckDB/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt b/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/DuckDB/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt new file mode 100644 index 0000000000..82824f664e --- /dev/null +++ b/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/DuckDB/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt @@ -0,0 +1,17 @@ +booking__ds__martian_day bookings_join_to_time_spine +-------------------------- ----------------------------- +2020-01-01T00:00:00 None +2020-01-02T00:00:00 None +2020-01-03T00:00:00 None +2020-01-04T00:00:00 None +2020-01-05T00:00:00 None +2020-01-06T00:00:00 None +2020-01-07T00:00:00 None +2020-01-08T00:00:00 46 +2020-01-09T00:00:00 None +2020-01-10T00:00:00 None +2020-01-11T00:00:00 None +2020-01-12T00:00:00 None +2020-01-13T00:00:00 None +2020-01-14T00:00:00 None +2020-01-15T00:00:00 None diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Postgres/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt b/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Postgres/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt new file mode 100644 index 0000000000..82824f664e --- /dev/null +++ b/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Postgres/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt @@ -0,0 +1,17 @@ +booking__ds__martian_day bookings_join_to_time_spine +-------------------------- ----------------------------- +2020-01-01T00:00:00 None +2020-01-02T00:00:00 None +2020-01-03T00:00:00 None +2020-01-04T00:00:00 None +2020-01-05T00:00:00 None +2020-01-06T00:00:00 None +2020-01-07T00:00:00 None +2020-01-08T00:00:00 46 +2020-01-09T00:00:00 None +2020-01-10T00:00:00 None +2020-01-11T00:00:00 None +2020-01-12T00:00:00 None +2020-01-13T00:00:00 None +2020-01-14T00:00:00 None +2020-01-15T00:00:00 None diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Redshift/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt b/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Redshift/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt new file mode 100644 index 0000000000..82824f664e --- /dev/null +++ b/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Redshift/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt @@ -0,0 +1,17 @@ +booking__ds__martian_day bookings_join_to_time_spine +-------------------------- ----------------------------- +2020-01-01T00:00:00 None +2020-01-02T00:00:00 None +2020-01-03T00:00:00 None +2020-01-04T00:00:00 None +2020-01-05T00:00:00 None +2020-01-06T00:00:00 None +2020-01-07T00:00:00 None +2020-01-08T00:00:00 46 +2020-01-09T00:00:00 None +2020-01-10T00:00:00 None +2020-01-11T00:00:00 None +2020-01-12T00:00:00 None +2020-01-13T00:00:00 None +2020-01-14T00:00:00 None +2020-01-15T00:00:00 None diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Snowflake/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt b/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Snowflake/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt new file mode 100644 index 0000000000..d746e8293f --- /dev/null +++ b/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Snowflake/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt @@ -0,0 +1,17 @@ +BOOKING__DS__MARTIAN_DAY BOOKINGS_JOIN_TO_TIME_SPINE +-------------------------- ----------------------------- +2020-01-01T00:00:00 None +2020-01-02T00:00:00 None +2020-01-03T00:00:00 None +2020-01-04T00:00:00 None +2020-01-05T00:00:00 None +2020-01-06T00:00:00 None +2020-01-07T00:00:00 None +2020-01-08T00:00:00 46 +2020-01-09T00:00:00 None +2020-01-10T00:00:00 None +2020-01-11T00:00:00 None +2020-01-12T00:00:00 None +2020-01-13T00:00:00 None +2020-01-14T00:00:00 None +2020-01-15T00:00:00 None diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Trino/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt b/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Trino/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt new file mode 100644 index 0000000000..82824f664e --- /dev/null +++ b/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Trino/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt @@ -0,0 +1,17 @@ +booking__ds__martian_day bookings_join_to_time_spine +-------------------------- ----------------------------- +2020-01-01T00:00:00 None +2020-01-02T00:00:00 None +2020-01-03T00:00:00 None +2020-01-04T00:00:00 None +2020-01-05T00:00:00 None +2020-01-06T00:00:00 None +2020-01-07T00:00:00 None +2020-01-08T00:00:00 46 +2020-01-09T00:00:00 None +2020-01-10T00:00:00 None +2020-01-11T00:00:00 None +2020-01-12T00:00:00 None +2020-01-13T00:00:00 None +2020-01-14T00:00:00 None +2020-01-15T00:00:00 None