From 9ffa83b6c4bdc518050a6b1ac88c71a693fc05bb Mon Sep 17 00:00:00 2001 From: tlento Date: Tue, 14 Nov 2023 16:44:47 -0800 Subject: [PATCH 1/2] Add query output test for cumulative metric calculations Cumulative metric queries are very difficult to reason about, especially when we do automated date sliding to include all of the necessary input data. This commit adds some output tests, which can be compared against the input data config files for fct_bookings and fct_revenue for correctness. --- .../query_output/test_cumulative_metrics.py | 154 ++++++++++++++++++ ...th_non_adjustable_filter__query_output.txt | 3 + ...o_date_cumulative_metric__query_output.txt | 5 + ...tiple_cumulative_metrics__query_output.txt | 63 +++++++ ...ditive_cumulative_metric__query_output.txt | 4 + ...simple_cumulative_metric__query_output.txt | 91 +++++++++++ ...th_non_adjustable_filter__query_output.txt | 3 + ...o_date_cumulative_metric__query_output.txt | 5 + ...tiple_cumulative_metrics__query_output.txt | 63 +++++++ ...ditive_cumulative_metric__query_output.txt | 4 + ...simple_cumulative_metric__query_output.txt | 91 +++++++++++ ...th_non_adjustable_filter__query_output.txt | 3 + ...o_date_cumulative_metric__query_output.txt | 5 + ...tiple_cumulative_metrics__query_output.txt | 63 +++++++ ...ditive_cumulative_metric__query_output.txt | 4 + ...simple_cumulative_metric__query_output.txt | 91 +++++++++++ ...th_non_adjustable_filter__query_output.txt | 3 + ...o_date_cumulative_metric__query_output.txt | 5 + ...tiple_cumulative_metrics__query_output.txt | 63 +++++++ ...ditive_cumulative_metric__query_output.txt | 4 + ...simple_cumulative_metric__query_output.txt | 91 +++++++++++ ...th_non_adjustable_filter__query_output.txt | 3 + ...o_date_cumulative_metric__query_output.txt | 5 + ...tiple_cumulative_metrics__query_output.txt | 63 +++++++ ...ditive_cumulative_metric__query_output.txt | 4 + ...simple_cumulative_metric__query_output.txt | 91 +++++++++++ ...th_non_adjustable_filter__query_output.txt | 3 + ...o_date_cumulative_metric__query_output.txt | 5 + ...tiple_cumulative_metrics__query_output.txt | 63 +++++++ ...ditive_cumulative_metric__query_output.txt | 4 + ...simple_cumulative_metric__query_output.txt | 91 +++++++++++ 31 files changed, 1150 insertions(+) create mode 100644 metricflow/test/integration/query_output/test_cumulative_metrics.py create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_cumulative_metric_with_non_adjustable_filter__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_grain_to_date_cumulative_metric__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_multiple_cumulative_metrics__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_non_additive_cumulative_metric__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_simple_cumulative_metric__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_cumulative_metric_with_non_adjustable_filter__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_grain_to_date_cumulative_metric__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_multiple_cumulative_metrics__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_non_additive_cumulative_metric__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_simple_cumulative_metric__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_cumulative_metric_with_non_adjustable_filter__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_grain_to_date_cumulative_metric__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_multiple_cumulative_metrics__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_non_additive_cumulative_metric__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_simple_cumulative_metric__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_cumulative_metric_with_non_adjustable_filter__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_grain_to_date_cumulative_metric__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_multiple_cumulative_metrics__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_non_additive_cumulative_metric__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_simple_cumulative_metric__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_cumulative_metric_with_non_adjustable_filter__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_grain_to_date_cumulative_metric__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_multiple_cumulative_metrics__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_non_additive_cumulative_metric__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_simple_cumulative_metric__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_cumulative_metric_with_non_adjustable_filter__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_grain_to_date_cumulative_metric__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_multiple_cumulative_metrics__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_non_additive_cumulative_metric__query_output.txt create mode 100644 metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_simple_cumulative_metric__query_output.txt diff --git a/metricflow/test/integration/query_output/test_cumulative_metrics.py b/metricflow/test/integration/query_output/test_cumulative_metrics.py new file mode 100644 index 0000000000..e96ff2f4e7 --- /dev/null +++ b/metricflow/test/integration/query_output/test_cumulative_metrics.py @@ -0,0 +1,154 @@ +from __future__ import annotations + +import datetime + +import pytest +from _pytest.fixtures import FixtureRequest + +from metricflow.engine.metricflow_engine import MetricFlowQueryRequest +from metricflow.protocols.sql_client import SqlClient +from metricflow.test.fixtures.setup_fixtures import MetricFlowTestSessionState +from metricflow.test.integration.conftest import IntegrationTestHelpers +from metricflow.test.snapshot_utils import assert_object_snapshot_equal + + +@pytest.mark.sql_engine_snapshot +def test_simple_cumulative_metric( + request: FixtureRequest, + mf_test_session_state: MetricFlowTestSessionState, + sql_client: SqlClient, + it_helpers: IntegrationTestHelpers, +) -> None: + """Tests a query of a cumulative metric with a monthly window and a time constraint adjustment.""" + query_result = it_helpers.mf_engine.query( + MetricFlowQueryRequest.create_with_random_request_id( + metric_names=["trailing_2_months_revenue"], + group_by_names=["metric_time"], + order_by_names=["metric_time"], + time_constraint_start=datetime.datetime(2020, 2, 1), + time_constraint_end=datetime.datetime(2020, 4, 30), + ) + ) + assert query_result.result_df is not None, "Unexpected empty result." + + assert_object_snapshot_equal( + request=request, + mf_test_session_state=mf_test_session_state, + obj_id="query_output", + obj=query_result.result_df.to_string(), + sql_client=sql_client, + ) + + +@pytest.mark.sql_engine_snapshot +def test_multiple_cumulative_metrics( + request: FixtureRequest, + mf_test_session_state: MetricFlowTestSessionState, + sql_client: SqlClient, + it_helpers: IntegrationTestHelpers, +) -> None: + """Tests a query with multiple cumulative metrics to ensure date selections align.""" + query_result = it_helpers.mf_engine.query( + MetricFlowQueryRequest.create_with_random_request_id( + metric_names=["revenue_all_time", "trailing_2_months_revenue"], + group_by_names=["metric_time"], + order_by_names=["metric_time"], + time_constraint_start=datetime.datetime(2020, 3, 31), + time_constraint_end=datetime.datetime(2020, 5, 31), + ) + ) + assert query_result.result_df is not None, "Unexpected empty result." + + assert_object_snapshot_equal( + request=request, + mf_test_session_state=mf_test_session_state, + obj_id="query_output", + obj=query_result.result_df.to_string(), + sql_client=sql_client, + ) + + +@pytest.mark.sql_engine_snapshot +def test_non_additive_cumulative_metric( + request: FixtureRequest, + mf_test_session_state: MetricFlowTestSessionState, + sql_client: SqlClient, + it_helpers: IntegrationTestHelpers, +) -> None: + """Tests a query with a non-additive cumulative metric to ensure the non-additive constraint is applied.""" + query_result = it_helpers.mf_engine.query( + MetricFlowQueryRequest.create_with_random_request_id( + metric_names=["every_two_days_bookers"], + group_by_names=["metric_time"], + order_by_names=["metric_time"], + time_constraint_start=datetime.datetime(2019, 12, 31), + time_constraint_end=datetime.datetime(2020, 1, 3), + ) + ) + assert query_result.result_df is not None, "Unexpected empty result." + + assert_object_snapshot_equal( + request=request, + mf_test_session_state=mf_test_session_state, + obj_id="query_output", + obj=query_result.result_df.to_string(), + sql_client=sql_client, + ) + + +@pytest.mark.sql_engine_snapshot +def test_grain_to_date_cumulative_metric( + request: FixtureRequest, + mf_test_session_state: MetricFlowTestSessionState, + sql_client: SqlClient, + it_helpers: IntegrationTestHelpers, +) -> None: + """Tests a month to date cumulative metric with a constraint to ensure all necessary input data is included.""" + query_result = it_helpers.mf_engine.query( + MetricFlowQueryRequest.create_with_random_request_id( + metric_names=["revenue_mtd"], + group_by_names=["metric_time"], + order_by_names=["metric_time"], + time_constraint_start=datetime.datetime(2021, 1, 3), + time_constraint_end=datetime.datetime(2021, 1, 6), + ) + ) + assert query_result.result_df is not None, "Unexpected empty result." + + assert_object_snapshot_equal( + request=request, + mf_test_session_state=mf_test_session_state, + obj_id="query_output", + obj=query_result.result_df.to_string(), + sql_client=sql_client, + ) + + +@pytest.mark.sql_engine_snapshot +def test_cumulative_metric_with_non_adjustable_filter( + request: FixtureRequest, + mf_test_session_state: MetricFlowTestSessionState, + sql_client: SqlClient, + it_helpers: IntegrationTestHelpers, +) -> None: + """Tests a cumulative metric with a filter that cannot be adjusted to ensure all data is included.""" + query_result = it_helpers.mf_engine.query( + MetricFlowQueryRequest.create_with_random_request_id( + metric_names=["trailing_2_months_revenue"], + group_by_names=["metric_time"], + order_by_names=["metric_time"], + where_constraint=( + "{{ TimeDimension('metric_time', 'day') }} = '2020-03-15' or " + "{{ TimeDimension('metric_time', 'day') }} = '2020-04-30'" + ), + ) + ) + assert query_result.result_df is not None, "Unexpected empty result." + + assert_object_snapshot_equal( + request=request, + mf_test_session_state=mf_test_session_state, + obj_id="query_output", + obj=query_result.result_df.to_string(), + sql_client=sql_client, + ) diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_cumulative_metric_with_non_adjustable_filter__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_cumulative_metric_with_non_adjustable_filter__query_output.txt new file mode 100644 index 0000000000..a6e99f543d --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_cumulative_metric_with_non_adjustable_filter__query_output.txt @@ -0,0 +1,3 @@ + metric_time__day trailing_2_months_revenue +0 2020-03-15 7000 +1 2020-04-30 7000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_grain_to_date_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_grain_to_date_cumulative_metric__query_output.txt new file mode 100644 index 0000000000..68984bb861 --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_grain_to_date_cumulative_metric__query_output.txt @@ -0,0 +1,5 @@ + metric_time__day revenue_mtd +0 2021-01-03 1000 +1 2021-01-04 2000 +2 2021-01-05 2000 +3 2021-01-06 2000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_multiple_cumulative_metrics__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_multiple_cumulative_metrics__query_output.txt new file mode 100644 index 0000000000..018d8d3c50 --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_multiple_cumulative_metrics__query_output.txt @@ -0,0 +1,63 @@ + metric_time__day revenue_all_time trailing_2_months_revenue +0 2020-03-31 8000 3000 +1 2020-04-01 8000 3000 +2 2020-04-02 12000 7000 +3 2020-04-03 12000 7000 +4 2020-04-04 12000 7000 +5 2020-04-05 12000 7000 +6 2020-04-06 12000 7000 +7 2020-04-07 12000 7000 +8 2020-04-08 12000 7000 +9 2020-04-09 12000 7000 +10 2020-04-10 12000 7000 +11 2020-04-11 12000 7000 +12 2020-04-12 12000 7000 +13 2020-04-13 12000 7000 +14 2020-04-14 12000 7000 +15 2020-04-15 12000 7000 +16 2020-04-16 12000 7000 +17 2020-04-17 12000 7000 +18 2020-04-18 12000 7000 +19 2020-04-19 12000 7000 +20 2020-04-20 12000 7000 +21 2020-04-21 12000 7000 +22 2020-04-22 12000 7000 +23 2020-04-23 12000 7000 +24 2020-04-24 12000 7000 +25 2020-04-25 12000 7000 +26 2020-04-26 12000 7000 +27 2020-04-27 12000 7000 +28 2020-04-28 12000 7000 +29 2020-04-29 12000 7000 +30 2020-04-30 12000 7000 +31 2020-05-01 12000 4000 +32 2020-05-02 12000 4000 +33 2020-05-03 12000 4000 +34 2020-05-04 12000 4000 +35 2020-05-05 12000 4000 +36 2020-05-06 12000 4000 +37 2020-05-07 12000 4000 +38 2020-05-08 12000 4000 +39 2020-05-09 12000 4000 +40 2020-05-10 12000 4000 +41 2020-05-11 12000 4000 +42 2020-05-12 12000 4000 +43 2020-05-13 12000 4000 +44 2020-05-14 12000 4000 +45 2020-05-15 12000 4000 +46 2020-05-16 12000 4000 +47 2020-05-17 12000 4000 +48 2020-05-18 12000 4000 +49 2020-05-19 12000 4000 +50 2020-05-20 12000 4000 +51 2020-05-21 12000 4000 +52 2020-05-22 12000 4000 +53 2020-05-23 12000 4000 +54 2020-05-24 12000 4000 +55 2020-05-25 12000 4000 +56 2020-05-26 12000 4000 +57 2020-05-27 12000 4000 +58 2020-05-28 12000 4000 +59 2020-05-29 12000 4000 +60 2020-05-30 12000 4000 +61 2020-05-31 12000 4000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_non_additive_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_non_additive_cumulative_metric__query_output.txt new file mode 100644 index 0000000000..9875015274 --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_non_additive_cumulative_metric__query_output.txt @@ -0,0 +1,4 @@ + metric_time__day every_two_days_bookers +0 2020-01-01 3 +1 2020-01-02 6 +2 2020-01-03 4 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_simple_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_simple_cumulative_metric__query_output.txt new file mode 100644 index 0000000000..57564e85eb --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_simple_cumulative_metric__query_output.txt @@ -0,0 +1,91 @@ + metric_time__day trailing_2_months_revenue +0 2020-02-01 5000 +1 2020-02-02 5000 +2 2020-02-03 5000 +3 2020-02-04 5000 +4 2020-02-05 5000 +5 2020-02-06 5000 +6 2020-02-07 5000 +7 2020-02-08 5000 +8 2020-02-09 5000 +9 2020-02-10 5000 +10 2020-02-11 5000 +11 2020-02-12 5000 +12 2020-02-13 5000 +13 2020-02-14 5000 +14 2020-02-15 5000 +15 2020-02-16 5000 +16 2020-02-17 5000 +17 2020-02-18 5000 +18 2020-02-19 5000 +19 2020-02-20 5000 +20 2020-02-21 5000 +21 2020-02-22 5000 +22 2020-02-23 5000 +23 2020-02-24 5000 +24 2020-02-25 5000 +25 2020-02-26 5000 +26 2020-02-27 5000 +27 2020-02-28 5000 +28 2020-02-29 5000 +29 2020-03-01 7000 +30 2020-03-02 7000 +31 2020-03-03 7000 +32 2020-03-04 7000 +33 2020-03-05 7000 +34 2020-03-06 7000 +35 2020-03-07 7000 +36 2020-03-08 7000 +37 2020-03-09 7000 +38 2020-03-10 7000 +39 2020-03-11 7000 +40 2020-03-12 7000 +41 2020-03-13 7000 +42 2020-03-14 7000 +43 2020-03-15 7000 +44 2020-03-16 7000 +45 2020-03-17 7000 +46 2020-03-18 7000 +47 2020-03-19 7000 +48 2020-03-20 7000 +49 2020-03-21 7000 +50 2020-03-22 7000 +51 2020-03-23 7000 +52 2020-03-24 7000 +53 2020-03-25 7000 +54 2020-03-26 7000 +55 2020-03-27 7000 +56 2020-03-28 7000 +57 2020-03-29 7000 +58 2020-03-30 7000 +59 2020-03-31 7000 +60 2020-04-01 3000 +61 2020-04-02 7000 +62 2020-04-03 7000 +63 2020-04-04 7000 +64 2020-04-05 7000 +65 2020-04-06 7000 +66 2020-04-07 7000 +67 2020-04-08 7000 +68 2020-04-09 7000 +69 2020-04-10 7000 +70 2020-04-11 7000 +71 2020-04-12 7000 +72 2020-04-13 7000 +73 2020-04-14 7000 +74 2020-04-15 7000 +75 2020-04-16 7000 +76 2020-04-17 7000 +77 2020-04-18 7000 +78 2020-04-19 7000 +79 2020-04-20 7000 +80 2020-04-21 7000 +81 2020-04-22 7000 +82 2020-04-23 7000 +83 2020-04-24 7000 +84 2020-04-25 7000 +85 2020-04-26 7000 +86 2020-04-27 7000 +87 2020-04-28 7000 +88 2020-04-29 7000 +89 2020-04-30 7000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_cumulative_metric_with_non_adjustable_filter__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_cumulative_metric_with_non_adjustable_filter__query_output.txt new file mode 100644 index 0000000000..71203c48fa --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_cumulative_metric_with_non_adjustable_filter__query_output.txt @@ -0,0 +1,3 @@ + metric_time__day trailing_2_months_revenue +0 2020-03-15 00:00:00+00:00 7000 +1 2020-04-30 00:00:00+00:00 7000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_grain_to_date_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_grain_to_date_cumulative_metric__query_output.txt new file mode 100644 index 0000000000..1f2d148700 --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_grain_to_date_cumulative_metric__query_output.txt @@ -0,0 +1,5 @@ + metric_time__day revenue_mtd +0 2021-01-03 00:00:00+00:00 1000 +1 2021-01-04 00:00:00+00:00 2000 +2 2021-01-05 00:00:00+00:00 2000 +3 2021-01-06 00:00:00+00:00 2000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_multiple_cumulative_metrics__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_multiple_cumulative_metrics__query_output.txt new file mode 100644 index 0000000000..4d1d34f6bd --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_multiple_cumulative_metrics__query_output.txt @@ -0,0 +1,63 @@ + metric_time__day revenue_all_time trailing_2_months_revenue +0 2020-03-31 00:00:00+00:00 8000 3000 +1 2020-04-01 00:00:00+00:00 8000 3000 +2 2020-04-02 00:00:00+00:00 12000 7000 +3 2020-04-03 00:00:00+00:00 12000 7000 +4 2020-04-04 00:00:00+00:00 12000 7000 +5 2020-04-05 00:00:00+00:00 12000 7000 +6 2020-04-06 00:00:00+00:00 12000 7000 +7 2020-04-07 00:00:00+00:00 12000 7000 +8 2020-04-08 00:00:00+00:00 12000 7000 +9 2020-04-09 00:00:00+00:00 12000 7000 +10 2020-04-10 00:00:00+00:00 12000 7000 +11 2020-04-11 00:00:00+00:00 12000 7000 +12 2020-04-12 00:00:00+00:00 12000 7000 +13 2020-04-13 00:00:00+00:00 12000 7000 +14 2020-04-14 00:00:00+00:00 12000 7000 +15 2020-04-15 00:00:00+00:00 12000 7000 +16 2020-04-16 00:00:00+00:00 12000 7000 +17 2020-04-17 00:00:00+00:00 12000 7000 +18 2020-04-18 00:00:00+00:00 12000 7000 +19 2020-04-19 00:00:00+00:00 12000 7000 +20 2020-04-20 00:00:00+00:00 12000 7000 +21 2020-04-21 00:00:00+00:00 12000 7000 +22 2020-04-22 00:00:00+00:00 12000 7000 +23 2020-04-23 00:00:00+00:00 12000 7000 +24 2020-04-24 00:00:00+00:00 12000 7000 +25 2020-04-25 00:00:00+00:00 12000 7000 +26 2020-04-26 00:00:00+00:00 12000 7000 +27 2020-04-27 00:00:00+00:00 12000 7000 +28 2020-04-28 00:00:00+00:00 12000 7000 +29 2020-04-29 00:00:00+00:00 12000 7000 +30 2020-04-30 00:00:00+00:00 12000 7000 +31 2020-05-01 00:00:00+00:00 12000 4000 +32 2020-05-02 00:00:00+00:00 12000 4000 +33 2020-05-03 00:00:00+00:00 12000 4000 +34 2020-05-04 00:00:00+00:00 12000 4000 +35 2020-05-05 00:00:00+00:00 12000 4000 +36 2020-05-06 00:00:00+00:00 12000 4000 +37 2020-05-07 00:00:00+00:00 12000 4000 +38 2020-05-08 00:00:00+00:00 12000 4000 +39 2020-05-09 00:00:00+00:00 12000 4000 +40 2020-05-10 00:00:00+00:00 12000 4000 +41 2020-05-11 00:00:00+00:00 12000 4000 +42 2020-05-12 00:00:00+00:00 12000 4000 +43 2020-05-13 00:00:00+00:00 12000 4000 +44 2020-05-14 00:00:00+00:00 12000 4000 +45 2020-05-15 00:00:00+00:00 12000 4000 +46 2020-05-16 00:00:00+00:00 12000 4000 +47 2020-05-17 00:00:00+00:00 12000 4000 +48 2020-05-18 00:00:00+00:00 12000 4000 +49 2020-05-19 00:00:00+00:00 12000 4000 +50 2020-05-20 00:00:00+00:00 12000 4000 +51 2020-05-21 00:00:00+00:00 12000 4000 +52 2020-05-22 00:00:00+00:00 12000 4000 +53 2020-05-23 00:00:00+00:00 12000 4000 +54 2020-05-24 00:00:00+00:00 12000 4000 +55 2020-05-25 00:00:00+00:00 12000 4000 +56 2020-05-26 00:00:00+00:00 12000 4000 +57 2020-05-27 00:00:00+00:00 12000 4000 +58 2020-05-28 00:00:00+00:00 12000 4000 +59 2020-05-29 00:00:00+00:00 12000 4000 +60 2020-05-30 00:00:00+00:00 12000 4000 +61 2020-05-31 00:00:00+00:00 12000 4000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_non_additive_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_non_additive_cumulative_metric__query_output.txt new file mode 100644 index 0000000000..3fd04c9473 --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_non_additive_cumulative_metric__query_output.txt @@ -0,0 +1,4 @@ + metric_time__day every_two_days_bookers +0 2020-01-01 00:00:00+00:00 3 +1 2020-01-02 00:00:00+00:00 6 +2 2020-01-03 00:00:00+00:00 4 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_simple_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_simple_cumulative_metric__query_output.txt new file mode 100644 index 0000000000..05d14d652a --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_simple_cumulative_metric__query_output.txt @@ -0,0 +1,91 @@ + metric_time__day trailing_2_months_revenue +0 2020-02-01 00:00:00+00:00 5000 +1 2020-02-02 00:00:00+00:00 5000 +2 2020-02-03 00:00:00+00:00 5000 +3 2020-02-04 00:00:00+00:00 5000 +4 2020-02-05 00:00:00+00:00 5000 +5 2020-02-06 00:00:00+00:00 5000 +6 2020-02-07 00:00:00+00:00 5000 +7 2020-02-08 00:00:00+00:00 5000 +8 2020-02-09 00:00:00+00:00 5000 +9 2020-02-10 00:00:00+00:00 5000 +10 2020-02-11 00:00:00+00:00 5000 +11 2020-02-12 00:00:00+00:00 5000 +12 2020-02-13 00:00:00+00:00 5000 +13 2020-02-14 00:00:00+00:00 5000 +14 2020-02-15 00:00:00+00:00 5000 +15 2020-02-16 00:00:00+00:00 5000 +16 2020-02-17 00:00:00+00:00 5000 +17 2020-02-18 00:00:00+00:00 5000 +18 2020-02-19 00:00:00+00:00 5000 +19 2020-02-20 00:00:00+00:00 5000 +20 2020-02-21 00:00:00+00:00 5000 +21 2020-02-22 00:00:00+00:00 5000 +22 2020-02-23 00:00:00+00:00 5000 +23 2020-02-24 00:00:00+00:00 5000 +24 2020-02-25 00:00:00+00:00 5000 +25 2020-02-26 00:00:00+00:00 5000 +26 2020-02-27 00:00:00+00:00 5000 +27 2020-02-28 00:00:00+00:00 5000 +28 2020-02-29 00:00:00+00:00 5000 +29 2020-03-01 00:00:00+00:00 7000 +30 2020-03-02 00:00:00+00:00 7000 +31 2020-03-03 00:00:00+00:00 7000 +32 2020-03-04 00:00:00+00:00 7000 +33 2020-03-05 00:00:00+00:00 7000 +34 2020-03-06 00:00:00+00:00 7000 +35 2020-03-07 00:00:00+00:00 7000 +36 2020-03-08 00:00:00+00:00 7000 +37 2020-03-09 00:00:00+00:00 7000 +38 2020-03-10 00:00:00+00:00 7000 +39 2020-03-11 00:00:00+00:00 7000 +40 2020-03-12 00:00:00+00:00 7000 +41 2020-03-13 00:00:00+00:00 7000 +42 2020-03-14 00:00:00+00:00 7000 +43 2020-03-15 00:00:00+00:00 7000 +44 2020-03-16 00:00:00+00:00 7000 +45 2020-03-17 00:00:00+00:00 7000 +46 2020-03-18 00:00:00+00:00 7000 +47 2020-03-19 00:00:00+00:00 7000 +48 2020-03-20 00:00:00+00:00 7000 +49 2020-03-21 00:00:00+00:00 7000 +50 2020-03-22 00:00:00+00:00 7000 +51 2020-03-23 00:00:00+00:00 7000 +52 2020-03-24 00:00:00+00:00 7000 +53 2020-03-25 00:00:00+00:00 7000 +54 2020-03-26 00:00:00+00:00 7000 +55 2020-03-27 00:00:00+00:00 7000 +56 2020-03-28 00:00:00+00:00 7000 +57 2020-03-29 00:00:00+00:00 7000 +58 2020-03-30 00:00:00+00:00 7000 +59 2020-03-31 00:00:00+00:00 7000 +60 2020-04-01 00:00:00+00:00 3000 +61 2020-04-02 00:00:00+00:00 7000 +62 2020-04-03 00:00:00+00:00 7000 +63 2020-04-04 00:00:00+00:00 7000 +64 2020-04-05 00:00:00+00:00 7000 +65 2020-04-06 00:00:00+00:00 7000 +66 2020-04-07 00:00:00+00:00 7000 +67 2020-04-08 00:00:00+00:00 7000 +68 2020-04-09 00:00:00+00:00 7000 +69 2020-04-10 00:00:00+00:00 7000 +70 2020-04-11 00:00:00+00:00 7000 +71 2020-04-12 00:00:00+00:00 7000 +72 2020-04-13 00:00:00+00:00 7000 +73 2020-04-14 00:00:00+00:00 7000 +74 2020-04-15 00:00:00+00:00 7000 +75 2020-04-16 00:00:00+00:00 7000 +76 2020-04-17 00:00:00+00:00 7000 +77 2020-04-18 00:00:00+00:00 7000 +78 2020-04-19 00:00:00+00:00 7000 +79 2020-04-20 00:00:00+00:00 7000 +80 2020-04-21 00:00:00+00:00 7000 +81 2020-04-22 00:00:00+00:00 7000 +82 2020-04-23 00:00:00+00:00 7000 +83 2020-04-24 00:00:00+00:00 7000 +84 2020-04-25 00:00:00+00:00 7000 +85 2020-04-26 00:00:00+00:00 7000 +86 2020-04-27 00:00:00+00:00 7000 +87 2020-04-28 00:00:00+00:00 7000 +88 2020-04-29 00:00:00+00:00 7000 +89 2020-04-30 00:00:00+00:00 7000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_cumulative_metric_with_non_adjustable_filter__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_cumulative_metric_with_non_adjustable_filter__query_output.txt new file mode 100644 index 0000000000..a6e99f543d --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_cumulative_metric_with_non_adjustable_filter__query_output.txt @@ -0,0 +1,3 @@ + metric_time__day trailing_2_months_revenue +0 2020-03-15 7000 +1 2020-04-30 7000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_grain_to_date_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_grain_to_date_cumulative_metric__query_output.txt new file mode 100644 index 0000000000..68984bb861 --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_grain_to_date_cumulative_metric__query_output.txt @@ -0,0 +1,5 @@ + metric_time__day revenue_mtd +0 2021-01-03 1000 +1 2021-01-04 2000 +2 2021-01-05 2000 +3 2021-01-06 2000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_multiple_cumulative_metrics__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_multiple_cumulative_metrics__query_output.txt new file mode 100644 index 0000000000..018d8d3c50 --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_multiple_cumulative_metrics__query_output.txt @@ -0,0 +1,63 @@ + metric_time__day revenue_all_time trailing_2_months_revenue +0 2020-03-31 8000 3000 +1 2020-04-01 8000 3000 +2 2020-04-02 12000 7000 +3 2020-04-03 12000 7000 +4 2020-04-04 12000 7000 +5 2020-04-05 12000 7000 +6 2020-04-06 12000 7000 +7 2020-04-07 12000 7000 +8 2020-04-08 12000 7000 +9 2020-04-09 12000 7000 +10 2020-04-10 12000 7000 +11 2020-04-11 12000 7000 +12 2020-04-12 12000 7000 +13 2020-04-13 12000 7000 +14 2020-04-14 12000 7000 +15 2020-04-15 12000 7000 +16 2020-04-16 12000 7000 +17 2020-04-17 12000 7000 +18 2020-04-18 12000 7000 +19 2020-04-19 12000 7000 +20 2020-04-20 12000 7000 +21 2020-04-21 12000 7000 +22 2020-04-22 12000 7000 +23 2020-04-23 12000 7000 +24 2020-04-24 12000 7000 +25 2020-04-25 12000 7000 +26 2020-04-26 12000 7000 +27 2020-04-27 12000 7000 +28 2020-04-28 12000 7000 +29 2020-04-29 12000 7000 +30 2020-04-30 12000 7000 +31 2020-05-01 12000 4000 +32 2020-05-02 12000 4000 +33 2020-05-03 12000 4000 +34 2020-05-04 12000 4000 +35 2020-05-05 12000 4000 +36 2020-05-06 12000 4000 +37 2020-05-07 12000 4000 +38 2020-05-08 12000 4000 +39 2020-05-09 12000 4000 +40 2020-05-10 12000 4000 +41 2020-05-11 12000 4000 +42 2020-05-12 12000 4000 +43 2020-05-13 12000 4000 +44 2020-05-14 12000 4000 +45 2020-05-15 12000 4000 +46 2020-05-16 12000 4000 +47 2020-05-17 12000 4000 +48 2020-05-18 12000 4000 +49 2020-05-19 12000 4000 +50 2020-05-20 12000 4000 +51 2020-05-21 12000 4000 +52 2020-05-22 12000 4000 +53 2020-05-23 12000 4000 +54 2020-05-24 12000 4000 +55 2020-05-25 12000 4000 +56 2020-05-26 12000 4000 +57 2020-05-27 12000 4000 +58 2020-05-28 12000 4000 +59 2020-05-29 12000 4000 +60 2020-05-30 12000 4000 +61 2020-05-31 12000 4000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_non_additive_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_non_additive_cumulative_metric__query_output.txt new file mode 100644 index 0000000000..9875015274 --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_non_additive_cumulative_metric__query_output.txt @@ -0,0 +1,4 @@ + metric_time__day every_two_days_bookers +0 2020-01-01 3 +1 2020-01-02 6 +2 2020-01-03 4 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_simple_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_simple_cumulative_metric__query_output.txt new file mode 100644 index 0000000000..57564e85eb --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_simple_cumulative_metric__query_output.txt @@ -0,0 +1,91 @@ + metric_time__day trailing_2_months_revenue +0 2020-02-01 5000 +1 2020-02-02 5000 +2 2020-02-03 5000 +3 2020-02-04 5000 +4 2020-02-05 5000 +5 2020-02-06 5000 +6 2020-02-07 5000 +7 2020-02-08 5000 +8 2020-02-09 5000 +9 2020-02-10 5000 +10 2020-02-11 5000 +11 2020-02-12 5000 +12 2020-02-13 5000 +13 2020-02-14 5000 +14 2020-02-15 5000 +15 2020-02-16 5000 +16 2020-02-17 5000 +17 2020-02-18 5000 +18 2020-02-19 5000 +19 2020-02-20 5000 +20 2020-02-21 5000 +21 2020-02-22 5000 +22 2020-02-23 5000 +23 2020-02-24 5000 +24 2020-02-25 5000 +25 2020-02-26 5000 +26 2020-02-27 5000 +27 2020-02-28 5000 +28 2020-02-29 5000 +29 2020-03-01 7000 +30 2020-03-02 7000 +31 2020-03-03 7000 +32 2020-03-04 7000 +33 2020-03-05 7000 +34 2020-03-06 7000 +35 2020-03-07 7000 +36 2020-03-08 7000 +37 2020-03-09 7000 +38 2020-03-10 7000 +39 2020-03-11 7000 +40 2020-03-12 7000 +41 2020-03-13 7000 +42 2020-03-14 7000 +43 2020-03-15 7000 +44 2020-03-16 7000 +45 2020-03-17 7000 +46 2020-03-18 7000 +47 2020-03-19 7000 +48 2020-03-20 7000 +49 2020-03-21 7000 +50 2020-03-22 7000 +51 2020-03-23 7000 +52 2020-03-24 7000 +53 2020-03-25 7000 +54 2020-03-26 7000 +55 2020-03-27 7000 +56 2020-03-28 7000 +57 2020-03-29 7000 +58 2020-03-30 7000 +59 2020-03-31 7000 +60 2020-04-01 3000 +61 2020-04-02 7000 +62 2020-04-03 7000 +63 2020-04-04 7000 +64 2020-04-05 7000 +65 2020-04-06 7000 +66 2020-04-07 7000 +67 2020-04-08 7000 +68 2020-04-09 7000 +69 2020-04-10 7000 +70 2020-04-11 7000 +71 2020-04-12 7000 +72 2020-04-13 7000 +73 2020-04-14 7000 +74 2020-04-15 7000 +75 2020-04-16 7000 +76 2020-04-17 7000 +77 2020-04-18 7000 +78 2020-04-19 7000 +79 2020-04-20 7000 +80 2020-04-21 7000 +81 2020-04-22 7000 +82 2020-04-23 7000 +83 2020-04-24 7000 +84 2020-04-25 7000 +85 2020-04-26 7000 +86 2020-04-27 7000 +87 2020-04-28 7000 +88 2020-04-29 7000 +89 2020-04-30 7000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_cumulative_metric_with_non_adjustable_filter__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_cumulative_metric_with_non_adjustable_filter__query_output.txt new file mode 100644 index 0000000000..041c8442ed --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_cumulative_metric_with_non_adjustable_filter__query_output.txt @@ -0,0 +1,3 @@ + metric_time__day trailing_2_months_revenue +0 2020-03-15 7000 +1 2020-04-30 7000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_grain_to_date_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_grain_to_date_cumulative_metric__query_output.txt new file mode 100644 index 0000000000..19b53d70d1 --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_grain_to_date_cumulative_metric__query_output.txt @@ -0,0 +1,5 @@ + metric_time__day revenue_mtd +0 2021-01-03 1000 +1 2021-01-04 2000 +2 2021-01-05 2000 +3 2021-01-06 2000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_multiple_cumulative_metrics__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_multiple_cumulative_metrics__query_output.txt new file mode 100644 index 0000000000..57e10f784b --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_multiple_cumulative_metrics__query_output.txt @@ -0,0 +1,63 @@ + metric_time__day revenue_all_time trailing_2_months_revenue +0 2020-03-31 8000 3000 +1 2020-04-01 8000 3000 +2 2020-04-02 12000 7000 +3 2020-04-03 12000 7000 +4 2020-04-04 12000 7000 +5 2020-04-05 12000 7000 +6 2020-04-06 12000 7000 +7 2020-04-07 12000 7000 +8 2020-04-08 12000 7000 +9 2020-04-09 12000 7000 +10 2020-04-10 12000 7000 +11 2020-04-11 12000 7000 +12 2020-04-12 12000 7000 +13 2020-04-13 12000 7000 +14 2020-04-14 12000 7000 +15 2020-04-15 12000 7000 +16 2020-04-16 12000 7000 +17 2020-04-17 12000 7000 +18 2020-04-18 12000 7000 +19 2020-04-19 12000 7000 +20 2020-04-20 12000 7000 +21 2020-04-21 12000 7000 +22 2020-04-22 12000 7000 +23 2020-04-23 12000 7000 +24 2020-04-24 12000 7000 +25 2020-04-25 12000 7000 +26 2020-04-26 12000 7000 +27 2020-04-27 12000 7000 +28 2020-04-28 12000 7000 +29 2020-04-29 12000 7000 +30 2020-04-30 12000 7000 +31 2020-05-01 12000 4000 +32 2020-05-02 12000 4000 +33 2020-05-03 12000 4000 +34 2020-05-04 12000 4000 +35 2020-05-05 12000 4000 +36 2020-05-06 12000 4000 +37 2020-05-07 12000 4000 +38 2020-05-08 12000 4000 +39 2020-05-09 12000 4000 +40 2020-05-10 12000 4000 +41 2020-05-11 12000 4000 +42 2020-05-12 12000 4000 +43 2020-05-13 12000 4000 +44 2020-05-14 12000 4000 +45 2020-05-15 12000 4000 +46 2020-05-16 12000 4000 +47 2020-05-17 12000 4000 +48 2020-05-18 12000 4000 +49 2020-05-19 12000 4000 +50 2020-05-20 12000 4000 +51 2020-05-21 12000 4000 +52 2020-05-22 12000 4000 +53 2020-05-23 12000 4000 +54 2020-05-24 12000 4000 +55 2020-05-25 12000 4000 +56 2020-05-26 12000 4000 +57 2020-05-27 12000 4000 +58 2020-05-28 12000 4000 +59 2020-05-29 12000 4000 +60 2020-05-30 12000 4000 +61 2020-05-31 12000 4000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_non_additive_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_non_additive_cumulative_metric__query_output.txt new file mode 100644 index 0000000000..9875015274 --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_non_additive_cumulative_metric__query_output.txt @@ -0,0 +1,4 @@ + metric_time__day every_two_days_bookers +0 2020-01-01 3 +1 2020-01-02 6 +2 2020-01-03 4 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_simple_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_simple_cumulative_metric__query_output.txt new file mode 100644 index 0000000000..84fbc88f10 --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_simple_cumulative_metric__query_output.txt @@ -0,0 +1,91 @@ + metric_time__day trailing_2_months_revenue +0 2020-02-01 5000 +1 2020-02-02 5000 +2 2020-02-03 5000 +3 2020-02-04 5000 +4 2020-02-05 5000 +5 2020-02-06 5000 +6 2020-02-07 5000 +7 2020-02-08 5000 +8 2020-02-09 5000 +9 2020-02-10 5000 +10 2020-02-11 5000 +11 2020-02-12 5000 +12 2020-02-13 5000 +13 2020-02-14 5000 +14 2020-02-15 5000 +15 2020-02-16 5000 +16 2020-02-17 5000 +17 2020-02-18 5000 +18 2020-02-19 5000 +19 2020-02-20 5000 +20 2020-02-21 5000 +21 2020-02-22 5000 +22 2020-02-23 5000 +23 2020-02-24 5000 +24 2020-02-25 5000 +25 2020-02-26 5000 +26 2020-02-27 5000 +27 2020-02-28 5000 +28 2020-02-29 5000 +29 2020-03-01 7000 +30 2020-03-02 7000 +31 2020-03-03 7000 +32 2020-03-04 7000 +33 2020-03-05 7000 +34 2020-03-06 7000 +35 2020-03-07 7000 +36 2020-03-08 7000 +37 2020-03-09 7000 +38 2020-03-10 7000 +39 2020-03-11 7000 +40 2020-03-12 7000 +41 2020-03-13 7000 +42 2020-03-14 7000 +43 2020-03-15 7000 +44 2020-03-16 7000 +45 2020-03-17 7000 +46 2020-03-18 7000 +47 2020-03-19 7000 +48 2020-03-20 7000 +49 2020-03-21 7000 +50 2020-03-22 7000 +51 2020-03-23 7000 +52 2020-03-24 7000 +53 2020-03-25 7000 +54 2020-03-26 7000 +55 2020-03-27 7000 +56 2020-03-28 7000 +57 2020-03-29 7000 +58 2020-03-30 7000 +59 2020-03-31 7000 +60 2020-04-01 3000 +61 2020-04-02 7000 +62 2020-04-03 7000 +63 2020-04-04 7000 +64 2020-04-05 7000 +65 2020-04-06 7000 +66 2020-04-07 7000 +67 2020-04-08 7000 +68 2020-04-09 7000 +69 2020-04-10 7000 +70 2020-04-11 7000 +71 2020-04-12 7000 +72 2020-04-13 7000 +73 2020-04-14 7000 +74 2020-04-15 7000 +75 2020-04-16 7000 +76 2020-04-17 7000 +77 2020-04-18 7000 +78 2020-04-19 7000 +79 2020-04-20 7000 +80 2020-04-21 7000 +81 2020-04-22 7000 +82 2020-04-23 7000 +83 2020-04-24 7000 +84 2020-04-25 7000 +85 2020-04-26 7000 +86 2020-04-27 7000 +87 2020-04-28 7000 +88 2020-04-29 7000 +89 2020-04-30 7000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_cumulative_metric_with_non_adjustable_filter__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_cumulative_metric_with_non_adjustable_filter__query_output.txt new file mode 100644 index 0000000000..a6e99f543d --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_cumulative_metric_with_non_adjustable_filter__query_output.txt @@ -0,0 +1,3 @@ + metric_time__day trailing_2_months_revenue +0 2020-03-15 7000 +1 2020-04-30 7000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_grain_to_date_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_grain_to_date_cumulative_metric__query_output.txt new file mode 100644 index 0000000000..68984bb861 --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_grain_to_date_cumulative_metric__query_output.txt @@ -0,0 +1,5 @@ + metric_time__day revenue_mtd +0 2021-01-03 1000 +1 2021-01-04 2000 +2 2021-01-05 2000 +3 2021-01-06 2000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_multiple_cumulative_metrics__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_multiple_cumulative_metrics__query_output.txt new file mode 100644 index 0000000000..018d8d3c50 --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_multiple_cumulative_metrics__query_output.txt @@ -0,0 +1,63 @@ + metric_time__day revenue_all_time trailing_2_months_revenue +0 2020-03-31 8000 3000 +1 2020-04-01 8000 3000 +2 2020-04-02 12000 7000 +3 2020-04-03 12000 7000 +4 2020-04-04 12000 7000 +5 2020-04-05 12000 7000 +6 2020-04-06 12000 7000 +7 2020-04-07 12000 7000 +8 2020-04-08 12000 7000 +9 2020-04-09 12000 7000 +10 2020-04-10 12000 7000 +11 2020-04-11 12000 7000 +12 2020-04-12 12000 7000 +13 2020-04-13 12000 7000 +14 2020-04-14 12000 7000 +15 2020-04-15 12000 7000 +16 2020-04-16 12000 7000 +17 2020-04-17 12000 7000 +18 2020-04-18 12000 7000 +19 2020-04-19 12000 7000 +20 2020-04-20 12000 7000 +21 2020-04-21 12000 7000 +22 2020-04-22 12000 7000 +23 2020-04-23 12000 7000 +24 2020-04-24 12000 7000 +25 2020-04-25 12000 7000 +26 2020-04-26 12000 7000 +27 2020-04-27 12000 7000 +28 2020-04-28 12000 7000 +29 2020-04-29 12000 7000 +30 2020-04-30 12000 7000 +31 2020-05-01 12000 4000 +32 2020-05-02 12000 4000 +33 2020-05-03 12000 4000 +34 2020-05-04 12000 4000 +35 2020-05-05 12000 4000 +36 2020-05-06 12000 4000 +37 2020-05-07 12000 4000 +38 2020-05-08 12000 4000 +39 2020-05-09 12000 4000 +40 2020-05-10 12000 4000 +41 2020-05-11 12000 4000 +42 2020-05-12 12000 4000 +43 2020-05-13 12000 4000 +44 2020-05-14 12000 4000 +45 2020-05-15 12000 4000 +46 2020-05-16 12000 4000 +47 2020-05-17 12000 4000 +48 2020-05-18 12000 4000 +49 2020-05-19 12000 4000 +50 2020-05-20 12000 4000 +51 2020-05-21 12000 4000 +52 2020-05-22 12000 4000 +53 2020-05-23 12000 4000 +54 2020-05-24 12000 4000 +55 2020-05-25 12000 4000 +56 2020-05-26 12000 4000 +57 2020-05-27 12000 4000 +58 2020-05-28 12000 4000 +59 2020-05-29 12000 4000 +60 2020-05-30 12000 4000 +61 2020-05-31 12000 4000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_non_additive_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_non_additive_cumulative_metric__query_output.txt new file mode 100644 index 0000000000..9875015274 --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_non_additive_cumulative_metric__query_output.txt @@ -0,0 +1,4 @@ + metric_time__day every_two_days_bookers +0 2020-01-01 3 +1 2020-01-02 6 +2 2020-01-03 4 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_simple_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_simple_cumulative_metric__query_output.txt new file mode 100644 index 0000000000..57564e85eb --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_simple_cumulative_metric__query_output.txt @@ -0,0 +1,91 @@ + metric_time__day trailing_2_months_revenue +0 2020-02-01 5000 +1 2020-02-02 5000 +2 2020-02-03 5000 +3 2020-02-04 5000 +4 2020-02-05 5000 +5 2020-02-06 5000 +6 2020-02-07 5000 +7 2020-02-08 5000 +8 2020-02-09 5000 +9 2020-02-10 5000 +10 2020-02-11 5000 +11 2020-02-12 5000 +12 2020-02-13 5000 +13 2020-02-14 5000 +14 2020-02-15 5000 +15 2020-02-16 5000 +16 2020-02-17 5000 +17 2020-02-18 5000 +18 2020-02-19 5000 +19 2020-02-20 5000 +20 2020-02-21 5000 +21 2020-02-22 5000 +22 2020-02-23 5000 +23 2020-02-24 5000 +24 2020-02-25 5000 +25 2020-02-26 5000 +26 2020-02-27 5000 +27 2020-02-28 5000 +28 2020-02-29 5000 +29 2020-03-01 7000 +30 2020-03-02 7000 +31 2020-03-03 7000 +32 2020-03-04 7000 +33 2020-03-05 7000 +34 2020-03-06 7000 +35 2020-03-07 7000 +36 2020-03-08 7000 +37 2020-03-09 7000 +38 2020-03-10 7000 +39 2020-03-11 7000 +40 2020-03-12 7000 +41 2020-03-13 7000 +42 2020-03-14 7000 +43 2020-03-15 7000 +44 2020-03-16 7000 +45 2020-03-17 7000 +46 2020-03-18 7000 +47 2020-03-19 7000 +48 2020-03-20 7000 +49 2020-03-21 7000 +50 2020-03-22 7000 +51 2020-03-23 7000 +52 2020-03-24 7000 +53 2020-03-25 7000 +54 2020-03-26 7000 +55 2020-03-27 7000 +56 2020-03-28 7000 +57 2020-03-29 7000 +58 2020-03-30 7000 +59 2020-03-31 7000 +60 2020-04-01 3000 +61 2020-04-02 7000 +62 2020-04-03 7000 +63 2020-04-04 7000 +64 2020-04-05 7000 +65 2020-04-06 7000 +66 2020-04-07 7000 +67 2020-04-08 7000 +68 2020-04-09 7000 +69 2020-04-10 7000 +70 2020-04-11 7000 +71 2020-04-12 7000 +72 2020-04-13 7000 +73 2020-04-14 7000 +74 2020-04-15 7000 +75 2020-04-16 7000 +76 2020-04-17 7000 +77 2020-04-18 7000 +78 2020-04-19 7000 +79 2020-04-20 7000 +80 2020-04-21 7000 +81 2020-04-22 7000 +82 2020-04-23 7000 +83 2020-04-24 7000 +84 2020-04-25 7000 +85 2020-04-26 7000 +86 2020-04-27 7000 +87 2020-04-28 7000 +88 2020-04-29 7000 +89 2020-04-30 7000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_cumulative_metric_with_non_adjustable_filter__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_cumulative_metric_with_non_adjustable_filter__query_output.txt new file mode 100644 index 0000000000..4485fb4b21 --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_cumulative_metric_with_non_adjustable_filter__query_output.txt @@ -0,0 +1,3 @@ + METRIC_TIME__DAY TRAILING_2_MONTHS_REVENUE +0 2020-03-15 7000 +1 2020-04-30 7000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_grain_to_date_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_grain_to_date_cumulative_metric__query_output.txt new file mode 100644 index 0000000000..75de445e78 --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_grain_to_date_cumulative_metric__query_output.txt @@ -0,0 +1,5 @@ + METRIC_TIME__DAY REVENUE_MTD +0 2021-01-03 1000 +1 2021-01-04 2000 +2 2021-01-05 2000 +3 2021-01-06 2000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_multiple_cumulative_metrics__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_multiple_cumulative_metrics__query_output.txt new file mode 100644 index 0000000000..d764f95899 --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_multiple_cumulative_metrics__query_output.txt @@ -0,0 +1,63 @@ + METRIC_TIME__DAY REVENUE_ALL_TIME TRAILING_2_MONTHS_REVENUE +0 2020-03-31 8000 3000 +1 2020-04-01 8000 3000 +2 2020-04-02 12000 7000 +3 2020-04-03 12000 7000 +4 2020-04-04 12000 7000 +5 2020-04-05 12000 7000 +6 2020-04-06 12000 7000 +7 2020-04-07 12000 7000 +8 2020-04-08 12000 7000 +9 2020-04-09 12000 7000 +10 2020-04-10 12000 7000 +11 2020-04-11 12000 7000 +12 2020-04-12 12000 7000 +13 2020-04-13 12000 7000 +14 2020-04-14 12000 7000 +15 2020-04-15 12000 7000 +16 2020-04-16 12000 7000 +17 2020-04-17 12000 7000 +18 2020-04-18 12000 7000 +19 2020-04-19 12000 7000 +20 2020-04-20 12000 7000 +21 2020-04-21 12000 7000 +22 2020-04-22 12000 7000 +23 2020-04-23 12000 7000 +24 2020-04-24 12000 7000 +25 2020-04-25 12000 7000 +26 2020-04-26 12000 7000 +27 2020-04-27 12000 7000 +28 2020-04-28 12000 7000 +29 2020-04-29 12000 7000 +30 2020-04-30 12000 7000 +31 2020-05-01 12000 4000 +32 2020-05-02 12000 4000 +33 2020-05-03 12000 4000 +34 2020-05-04 12000 4000 +35 2020-05-05 12000 4000 +36 2020-05-06 12000 4000 +37 2020-05-07 12000 4000 +38 2020-05-08 12000 4000 +39 2020-05-09 12000 4000 +40 2020-05-10 12000 4000 +41 2020-05-11 12000 4000 +42 2020-05-12 12000 4000 +43 2020-05-13 12000 4000 +44 2020-05-14 12000 4000 +45 2020-05-15 12000 4000 +46 2020-05-16 12000 4000 +47 2020-05-17 12000 4000 +48 2020-05-18 12000 4000 +49 2020-05-19 12000 4000 +50 2020-05-20 12000 4000 +51 2020-05-21 12000 4000 +52 2020-05-22 12000 4000 +53 2020-05-23 12000 4000 +54 2020-05-24 12000 4000 +55 2020-05-25 12000 4000 +56 2020-05-26 12000 4000 +57 2020-05-27 12000 4000 +58 2020-05-28 12000 4000 +59 2020-05-29 12000 4000 +60 2020-05-30 12000 4000 +61 2020-05-31 12000 4000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_non_additive_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_non_additive_cumulative_metric__query_output.txt new file mode 100644 index 0000000000..a4bac3b94a --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_non_additive_cumulative_metric__query_output.txt @@ -0,0 +1,4 @@ + METRIC_TIME__DAY EVERY_TWO_DAYS_BOOKERS +0 2020-01-01 3 +1 2020-01-02 6 +2 2020-01-03 4 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_simple_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_simple_cumulative_metric__query_output.txt new file mode 100644 index 0000000000..b0e46bbdd1 --- /dev/null +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_simple_cumulative_metric__query_output.txt @@ -0,0 +1,91 @@ + METRIC_TIME__DAY TRAILING_2_MONTHS_REVENUE +0 2020-02-01 5000 +1 2020-02-02 5000 +2 2020-02-03 5000 +3 2020-02-04 5000 +4 2020-02-05 5000 +5 2020-02-06 5000 +6 2020-02-07 5000 +7 2020-02-08 5000 +8 2020-02-09 5000 +9 2020-02-10 5000 +10 2020-02-11 5000 +11 2020-02-12 5000 +12 2020-02-13 5000 +13 2020-02-14 5000 +14 2020-02-15 5000 +15 2020-02-16 5000 +16 2020-02-17 5000 +17 2020-02-18 5000 +18 2020-02-19 5000 +19 2020-02-20 5000 +20 2020-02-21 5000 +21 2020-02-22 5000 +22 2020-02-23 5000 +23 2020-02-24 5000 +24 2020-02-25 5000 +25 2020-02-26 5000 +26 2020-02-27 5000 +27 2020-02-28 5000 +28 2020-02-29 5000 +29 2020-03-01 7000 +30 2020-03-02 7000 +31 2020-03-03 7000 +32 2020-03-04 7000 +33 2020-03-05 7000 +34 2020-03-06 7000 +35 2020-03-07 7000 +36 2020-03-08 7000 +37 2020-03-09 7000 +38 2020-03-10 7000 +39 2020-03-11 7000 +40 2020-03-12 7000 +41 2020-03-13 7000 +42 2020-03-14 7000 +43 2020-03-15 7000 +44 2020-03-16 7000 +45 2020-03-17 7000 +46 2020-03-18 7000 +47 2020-03-19 7000 +48 2020-03-20 7000 +49 2020-03-21 7000 +50 2020-03-22 7000 +51 2020-03-23 7000 +52 2020-03-24 7000 +53 2020-03-25 7000 +54 2020-03-26 7000 +55 2020-03-27 7000 +56 2020-03-28 7000 +57 2020-03-29 7000 +58 2020-03-30 7000 +59 2020-03-31 7000 +60 2020-04-01 3000 +61 2020-04-02 7000 +62 2020-04-03 7000 +63 2020-04-04 7000 +64 2020-04-05 7000 +65 2020-04-06 7000 +66 2020-04-07 7000 +67 2020-04-08 7000 +68 2020-04-09 7000 +69 2020-04-10 7000 +70 2020-04-11 7000 +71 2020-04-12 7000 +72 2020-04-13 7000 +73 2020-04-14 7000 +74 2020-04-15 7000 +75 2020-04-16 7000 +76 2020-04-17 7000 +77 2020-04-18 7000 +78 2020-04-19 7000 +79 2020-04-20 7000 +80 2020-04-21 7000 +81 2020-04-22 7000 +82 2020-04-23 7000 +83 2020-04-24 7000 +84 2020-04-25 7000 +85 2020-04-26 7000 +86 2020-04-27 7000 +87 2020-04-28 7000 +88 2020-04-29 7000 +89 2020-04-30 7000 From e628d6e3d1a54524eb2fbd721142a93bd647c36a Mon Sep 17 00:00:00 2001 From: tlento Date: Tue, 14 Nov 2023 17:02:59 -0800 Subject: [PATCH 2/2] Fix incorrect time constraint adjustment for cumulative metrics When users submit CLI queries with the --start-time and --end-time parameters, MetricFlow will automatically adjust the time constraint window to include all relevant cumulative metric input. Unfortunately, we got over-zealous with fencepost adjustments and introduced an off-by-one error that meant cumulative metric queries would only be correct when the specified granularity was DAILY. We never caught this issue because the error in the rendered SQL is subtle, and all of our test input data on the integration tests happened to fit within the artificially shortened constraint windows in all of the cases where we were testing non-daily granularity queries. This change updates the integration test configurations to ensure boundary conditions will be caught in the future. In addition, the fix alters the values of the query output snapshot tests, which, when compared with the relevant input test data, will reveal the nature of the original bug and the effects of this fix. --- .../unreleased/Fixes-20231114-171137.yaml | 6 ++++ metricflow/filters/time_constraint.py | 4 +-- .../test_cases/itest_cumulative_metric.yaml | 32 +++++++++++-------- ...ive_metric_with_time_constraint__plan0.sql | 4 +-- ..._with_time_constraint__plan0_optimized.sql | 4 +-- ...ive_metric_with_time_constraint__plan0.sql | 4 +-- ..._with_time_constraint__plan0_optimized.sql | 4 +-- ...ive_metric_with_time_constraint__plan0.sql | 4 +-- ..._with_time_constraint__plan0_optimized.sql | 4 +-- ...ive_metric_with_time_constraint__plan0.sql | 4 +-- ..._with_time_constraint__plan0_optimized.sql | 4 +-- ...ive_metric_with_time_constraint__plan0.sql | 4 +-- ..._with_time_constraint__plan0_optimized.sql | 4 +-- ...ive_metric_with_time_constraint__plan0.sql | 4 +-- ..._with_time_constraint__plan0_optimized.sql | 4 +-- ...o_date_cumulative_metric__query_output.txt | 8 ++--- ...tiple_cumulative_metrics__query_output.txt | 2 +- ...o_date_cumulative_metric__query_output.txt | 8 ++--- ...tiple_cumulative_metrics__query_output.txt | 2 +- ...o_date_cumulative_metric__query_output.txt | 8 ++--- ...tiple_cumulative_metrics__query_output.txt | 2 +- ...o_date_cumulative_metric__query_output.txt | 8 ++--- ...tiple_cumulative_metrics__query_output.txt | 2 +- ...o_date_cumulative_metric__query_output.txt | 8 ++--- ...tiple_cumulative_metrics__query_output.txt | 2 +- ...o_date_cumulative_metric__query_output.txt | 8 ++--- ...tiple_cumulative_metrics__query_output.txt | 2 +- 27 files changed, 81 insertions(+), 69 deletions(-) create mode 100644 .changes/unreleased/Fixes-20231114-171137.yaml diff --git a/.changes/unreleased/Fixes-20231114-171137.yaml b/.changes/unreleased/Fixes-20231114-171137.yaml new file mode 100644 index 0000000000..e5ff076258 --- /dev/null +++ b/.changes/unreleased/Fixes-20231114-171137.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Fix error in cumulative metric output when start-time and end-time are specified +time: 2023-11-14T17:11:37.462241-08:00 +custom: + Author: tlento + Issue: "869" diff --git a/metricflow/filters/time_constraint.py b/metricflow/filters/time_constraint.py index 165f33c539..4f8ece4b13 100644 --- a/metricflow/filters/time_constraint.py +++ b/metricflow/filters/time_constraint.py @@ -63,7 +63,7 @@ def _adjust_time_constraint_start_by_window( time_granularity: TimeGranularity, time_unit_count: int, ) -> TimeRangeConstraint: - """Moves the start of the time constraint back by 1 window. + """Moves the start of the time constraint back by windows. if the metric is weekly-active-users (ie window = 1 week) it moves time_constraint.start one week earlier """ @@ -80,7 +80,7 @@ def adjust_time_constraint_for_cumulative_metric( ) -> TimeRangeConstraint: """Given a time constraint for the overall query, adjust it to cover the time range for this metric.""" if granularity is not None: - return self._adjust_time_constraint_start_by_window(granularity, count - 1) + return self._adjust_time_constraint_start_by_window(granularity, count) # if no window is specified we want to accumulate from the beginning of time return TimeRangeConstraint( diff --git a/metricflow/test/integration/test_cases/itest_cumulative_metric.yaml b/metricflow/test/integration/test_cases/itest_cumulative_metric.yaml index 8913ba82bf..67b4315b2b 100644 --- a/metricflow/test/integration/test_cases/itest_cumulative_metric.yaml +++ b/metricflow/test/integration/test_cases/itest_cumulative_metric.yaml @@ -6,7 +6,7 @@ integration_test: metrics: ["trailing_2_months_revenue"] group_bys: ["metric_time"] order_bys: ["metric_time"] - time_constraint: ["2020-01-05", "2021-01-04"] + time_constraint: ["2020-03-05", "2021-01-04"] check_query: | SELECT SUM(b.txn_revenue) as trailing_2_months_revenue @@ -23,6 +23,7 @@ integration_test: FROM {{ source_schema }}.fct_revenue ) b ON b.ds <= a.ds AND b.ds > {{ render_date_sub("a", "ds", 2, TimeGranularity.MONTH) }} + WHERE {{ render_time_constraint("a.ds", "2020-03-05", "2021-01-04") }} GROUP BY a.ds ORDER BY a.ds --- @@ -33,7 +34,7 @@ integration_test: metrics: ["trailing_2_months_revenue"] group_bys: ["metric_time", "user__home_state_latest"] order_bys: ["metric_time", "user__home_state_latest"] - time_constraint: ["2020-01-05", "2021-01-04"] + time_constraint: ["2020-03-05", "2021-01-04"] check_query: | SELECT SUM(revenue) as trailing_2_months_revenue @@ -55,6 +56,7 @@ integration_test: GROUP BY m.created_at, m.revenue, u.home_state_latest ) b ON b.ds <= a.ds AND b.ds > {{ render_date_sub("a", "ds", 2, TimeGranularity.MONTH) }} + WHERE {{ render_time_constraint("a.ds", "2020-03-05", "2021-01-04") }} GROUP BY a.ds, user__home_state_latest ORDER by a.ds, user__home_state_latest --- @@ -65,7 +67,7 @@ integration_test: metrics: ["revenue_all_time"] group_bys: ["metric_time"] order_bys: ["metric_time"] - time_constraint: ["2020-01-01", "2021-01-05"] + time_constraint: ["2020-03-01", "2021-01-05"] check_query: | SELECT SUM(revenue) AS revenue_all_time @@ -73,7 +75,7 @@ integration_test: FROM ( SELECT ds FROM {{ mf_time_spine_source }} - WHERE {{ render_time_constraint("ds", "2020-01-01", "2021-01-05") }} + WHERE {{ render_time_constraint("ds", "2020-03-01", "2021-01-05") }} ) a INNER JOIN ( SELECT @@ -102,7 +104,7 @@ integration_test: metrics: ["revenue_all_time", "trailing_2_months_revenue"] group_bys: ["metric_time"] order_bys: ["metric_time"] - time_constraint: ["2019-12-31", "2021-01-05"] + time_constraint: ["2020-03-31", "2021-01-05"] check_query: | SELECT revenue_all_time, trailing_2_months_revenue, a.ds AS metric_time__day FROM ( @@ -116,7 +118,7 @@ integration_test: FROM ( SELECT ds FROM {{ mf_time_spine_source }} - WHERE {{ render_time_constraint("ds", "2019-12-31", "2021-01-05") }} + WHERE {{ render_time_constraint("ds", "2020-03-31", "2021-01-05") }} ) a INNER JOIN ( SELECT @@ -135,7 +137,7 @@ integration_test: FROM ( SELECT ds FROM {{ mf_time_spine_source }} - WHERE {{ render_time_constraint("ds", "2019-12-31", "2021-01-05") }} + WHERE {{ render_time_constraint("ds", "2020-01-31", "2021-01-05") }} ) a INNER JOIN ( SELECT @@ -147,6 +149,7 @@ integration_test: GROUP BY a.ds ) b ON a.ds = b.ds + WHERE {{ render_time_constraint("a.ds", "2020-03-31", "2021-01-05") }} ORDER BY a.ds --- integration_test: @@ -156,7 +159,7 @@ integration_test: metrics: ["trailing_2_months_revenue"] group_bys: ["metric_time__day"] order_bys: ["metric_time__day"] - time_constraint: ["2020-01-05", "2021-01-04"] + time_constraint: ["2020-03-05", "2021-01-04"] check_query: | SELECT SUM(b.txn_revenue) as trailing_2_months_revenue @@ -173,6 +176,7 @@ integration_test: FROM {{ source_schema }}.fct_revenue ) b ON b.ds <= a.ds AND b.ds > {{ render_date_sub("a", "ds", 2, TimeGranularity.MONTH) }} + WHERE {{ render_time_constraint("a.ds", "2020-03-05", "2021-01-04") }} GROUP BY a.ds ORDER BY a.ds --- @@ -218,7 +222,7 @@ integration_test: FROM ( SELECT ds FROM {{ mf_time_spine_source }} - WHERE {{ render_time_constraint("ds", "2019-12-31", "2020-01-04") }} + WHERE {{ render_time_constraint("ds", "2019-12-30", "2020-01-04") }} ) a INNER JOIN ( SELECT @@ -237,7 +241,7 @@ integration_test: metrics: ["every_two_days_bookers"] group_bys: ["metric_time"] order_bys: ["metric_time"] - time_constraint: ["2020-01-04", "2020-01-04"] + time_constraint: ["2020-01-03", "2020-01-03"] check_query: | SELECT COUNT (DISTINCT(b.guest_id)) as every_two_days_bookers @@ -245,7 +249,7 @@ integration_test: FROM ( SELECT ds FROM {{ mf_time_spine_source }} - WHERE {{ render_time_constraint("ds", "2020-01-04", "2020-01-04") }} + WHERE {{ render_time_constraint("ds", "2020-01-02", "2020-01-03") }} ) a INNER JOIN ( SELECT @@ -254,6 +258,7 @@ integration_test: FROM {{ source_schema }}.fct_bookings ) b ON b.ds <= a.ds AND b.ds > {{ render_date_sub("a", "ds", 2, TimeGranularity.DAY) }} + WHERE {{ render_time_constraint("a.ds", "2020-01-03", "2020-01-03") }} GROUP BY a.ds ORDER BY a.ds --- @@ -264,7 +269,7 @@ integration_test: metrics: ["revenue_mtd"] group_bys: ["metric_time"] order_bys: ["metric_time"] - time_constraint: ["2020-01-01", "2021-01-05"] + time_constraint: ["2021-01-04", "2021-01-05"] check_query: | SELECT SUM(b.txn_revenue) as revenue_mtd @@ -272,7 +277,7 @@ integration_test: FROM ( SELECT ds FROM {{ mf_time_spine_source }} - WHERE {{ render_time_constraint("ds", "2020-01-01", "2021-01-05") }} + WHERE {{ render_time_constraint("ds", "2021-01-01", "2021-01-05") }} ) a INNER JOIN ( SELECT @@ -281,6 +286,7 @@ integration_test: FROM {{ source_schema }}.fct_revenue ) b ON b.ds <= a.ds AND b.ds >= {{ render_date_trunc("a.ds", TimeGranularity.MONTH) }} + WHERE {{ render_time_constraint("a.ds", "2021-01-04", "2021-01-05") }} GROUP BY a.ds ORDER BY a.ds --- diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql index 68545a3501..02f70d25bb 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql @@ -65,7 +65,7 @@ FROM ( WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' ) subq_3 INNER JOIN ( - -- Constrain Time Range to [2019-12-01T00:00:00, 2020-01-01T00:00:00] + -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] SELECT subq_1.ds__day , subq_1.ds__week @@ -173,7 +173,7 @@ FROM ( FROM ***************************.fct_revenue revenue_src_10006 ) subq_0 ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2019-12-01' AND '2020-01-01' + WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' ) subq_2 ON ( diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 678e18f50d..ef1a5f85e5 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -17,13 +17,13 @@ FROM ( INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' - -- Constrain Time Range to [2019-12-01T00:00:00, 2020-01-01T00:00:00] + -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] SELECT DATE_TRUNC(created_at, day) AS metric_time__day , DATE_TRUNC(created_at, month) AS metric_time__month , revenue AS txn_revenue FROM ***************************.fct_revenue revenue_src_10006 - WHERE DATE_TRUNC(created_at, day) BETWEEN '2019-12-01' AND '2020-01-01' + WHERE DATE_TRUNC(created_at, day) BETWEEN '2019-11-01' AND '2020-01-01' ) subq_11 ON ( diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql index df2803e5e5..b3ed84f97d 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql @@ -65,7 +65,7 @@ FROM ( WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' ) subq_3 INNER JOIN ( - -- Constrain Time Range to [2019-12-01T00:00:00, 2020-01-01T00:00:00] + -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] SELECT subq_1.ds__day , subq_1.ds__week @@ -173,7 +173,7 @@ FROM ( FROM ***************************.fct_revenue revenue_src_10006 ) subq_0 ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2019-12-01' AND '2020-01-01' + WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' ) subq_2 ON ( diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 45c6dca4c2..5b70e3b1bf 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -17,13 +17,13 @@ FROM ( INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' - -- Constrain Time Range to [2019-12-01T00:00:00, 2020-01-01T00:00:00] + -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] SELECT DATE_TRUNC('day', created_at) AS metric_time__day , DATE_TRUNC('month', created_at) AS metric_time__month , revenue AS txn_revenue FROM ***************************.fct_revenue revenue_src_10006 - WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-12-01' AND '2020-01-01' + WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' ) subq_11 ON ( diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0.sql index 93416bb410..2afa239f5c 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0.sql @@ -65,7 +65,7 @@ FROM ( WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' ) subq_3 INNER JOIN ( - -- Constrain Time Range to [2019-12-01T00:00:00, 2020-01-01T00:00:00] + -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] SELECT subq_1.ds__day , subq_1.ds__week @@ -173,7 +173,7 @@ FROM ( FROM ***************************.fct_revenue revenue_src_10006 ) subq_0 ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2019-12-01' AND '2020-01-01' + WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' ) subq_2 ON ( diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index a4fbfb36ff..a07cb2047d 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -17,13 +17,13 @@ FROM ( INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' - -- Constrain Time Range to [2019-12-01T00:00:00, 2020-01-01T00:00:00] + -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] SELECT DATE_TRUNC('day', created_at) AS metric_time__day , DATE_TRUNC('month', created_at) AS metric_time__month , revenue AS txn_revenue FROM ***************************.fct_revenue revenue_src_10006 - WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-12-01' AND '2020-01-01' + WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' ) subq_11 ON ( diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql index 7d964e8569..7b83bc743e 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql @@ -65,7 +65,7 @@ FROM ( WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' ) subq_3 INNER JOIN ( - -- Constrain Time Range to [2019-12-01T00:00:00, 2020-01-01T00:00:00] + -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] SELECT subq_1.ds__day , subq_1.ds__week @@ -173,7 +173,7 @@ FROM ( FROM ***************************.fct_revenue revenue_src_10006 ) subq_0 ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2019-12-01' AND '2020-01-01' + WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' ) subq_2 ON ( diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 97600fe8d0..d9f814c03e 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -17,13 +17,13 @@ FROM ( INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' - -- Constrain Time Range to [2019-12-01T00:00:00, 2020-01-01T00:00:00] + -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] SELECT DATE_TRUNC('day', created_at) AS metric_time__day , DATE_TRUNC('month', created_at) AS metric_time__month , revenue AS txn_revenue FROM ***************************.fct_revenue revenue_src_10006 - WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-12-01' AND '2020-01-01' + WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' ) subq_11 ON ( diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql index abf19f5d24..d26ac1871a 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql @@ -65,7 +65,7 @@ FROM ( WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' ) subq_3 INNER JOIN ( - -- Constrain Time Range to [2019-12-01T00:00:00, 2020-01-01T00:00:00] + -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] SELECT subq_1.ds__day , subq_1.ds__week @@ -173,7 +173,7 @@ FROM ( FROM ***************************.fct_revenue revenue_src_10006 ) subq_0 ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2019-12-01' AND '2020-01-01' + WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' ) subq_2 ON ( diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 45c6dca4c2..5b70e3b1bf 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -17,13 +17,13 @@ FROM ( INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' - -- Constrain Time Range to [2019-12-01T00:00:00, 2020-01-01T00:00:00] + -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] SELECT DATE_TRUNC('day', created_at) AS metric_time__day , DATE_TRUNC('month', created_at) AS metric_time__month , revenue AS txn_revenue FROM ***************************.fct_revenue revenue_src_10006 - WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-12-01' AND '2020-01-01' + WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' ) subq_11 ON ( diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql index 1123031c43..baaff08bb6 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql @@ -65,7 +65,7 @@ FROM ( WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' ) subq_3 INNER JOIN ( - -- Constrain Time Range to [2019-12-01T00:00:00, 2020-01-01T00:00:00] + -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] SELECT subq_1.ds__day , subq_1.ds__week @@ -173,7 +173,7 @@ FROM ( FROM ***************************.fct_revenue revenue_src_10006 ) subq_0 ) subq_1 - WHERE subq_1.metric_time__day BETWEEN '2019-12-01' AND '2020-01-01' + WHERE subq_1.metric_time__day BETWEEN '2019-11-01' AND '2020-01-01' ) subq_2 ON ( diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 45c6dca4c2..5b70e3b1bf 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -17,13 +17,13 @@ FROM ( INNER JOIN ( -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' - -- Constrain Time Range to [2019-12-01T00:00:00, 2020-01-01T00:00:00] + -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] SELECT DATE_TRUNC('day', created_at) AS metric_time__day , DATE_TRUNC('month', created_at) AS metric_time__month , revenue AS txn_revenue FROM ***************************.fct_revenue revenue_src_10006 - WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-12-01' AND '2020-01-01' + WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' ) subq_11 ON ( diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_grain_to_date_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_grain_to_date_cumulative_metric__query_output.txt index 68984bb861..737fe3f4ca 100644 --- a/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_grain_to_date_cumulative_metric__query_output.txt +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_grain_to_date_cumulative_metric__query_output.txt @@ -1,5 +1,5 @@ metric_time__day revenue_mtd -0 2021-01-03 1000 -1 2021-01-04 2000 -2 2021-01-05 2000 -3 2021-01-06 2000 +0 2021-01-03 3000 +1 2021-01-04 4000 +2 2021-01-05 4000 +3 2021-01-06 4000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_multiple_cumulative_metrics__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_multiple_cumulative_metrics__query_output.txt index 018d8d3c50..00ddadd8bd 100644 --- a/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_multiple_cumulative_metrics__query_output.txt +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/BigQuery/test_multiple_cumulative_metrics__query_output.txt @@ -1,5 +1,5 @@ metric_time__day revenue_all_time trailing_2_months_revenue -0 2020-03-31 8000 3000 +0 2020-03-31 8000 7000 1 2020-04-01 8000 3000 2 2020-04-02 12000 7000 3 2020-04-03 12000 7000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_grain_to_date_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_grain_to_date_cumulative_metric__query_output.txt index 1f2d148700..64f19dac82 100644 --- a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_grain_to_date_cumulative_metric__query_output.txt +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_grain_to_date_cumulative_metric__query_output.txt @@ -1,5 +1,5 @@ metric_time__day revenue_mtd -0 2021-01-03 00:00:00+00:00 1000 -1 2021-01-04 00:00:00+00:00 2000 -2 2021-01-05 00:00:00+00:00 2000 -3 2021-01-06 00:00:00+00:00 2000 +0 2021-01-03 00:00:00+00:00 3000 +1 2021-01-04 00:00:00+00:00 4000 +2 2021-01-05 00:00:00+00:00 4000 +3 2021-01-06 00:00:00+00:00 4000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_multiple_cumulative_metrics__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_multiple_cumulative_metrics__query_output.txt index 4d1d34f6bd..0217082f25 100644 --- a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_multiple_cumulative_metrics__query_output.txt +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Databricks/test_multiple_cumulative_metrics__query_output.txt @@ -1,5 +1,5 @@ metric_time__day revenue_all_time trailing_2_months_revenue -0 2020-03-31 00:00:00+00:00 8000 3000 +0 2020-03-31 00:00:00+00:00 8000 7000 1 2020-04-01 00:00:00+00:00 8000 3000 2 2020-04-02 00:00:00+00:00 12000 7000 3 2020-04-03 00:00:00+00:00 12000 7000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_grain_to_date_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_grain_to_date_cumulative_metric__query_output.txt index 68984bb861..737fe3f4ca 100644 --- a/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_grain_to_date_cumulative_metric__query_output.txt +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_grain_to_date_cumulative_metric__query_output.txt @@ -1,5 +1,5 @@ metric_time__day revenue_mtd -0 2021-01-03 1000 -1 2021-01-04 2000 -2 2021-01-05 2000 -3 2021-01-06 2000 +0 2021-01-03 3000 +1 2021-01-04 4000 +2 2021-01-05 4000 +3 2021-01-06 4000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_multiple_cumulative_metrics__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_multiple_cumulative_metrics__query_output.txt index 018d8d3c50..00ddadd8bd 100644 --- a/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_multiple_cumulative_metrics__query_output.txt +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/DuckDB/test_multiple_cumulative_metrics__query_output.txt @@ -1,5 +1,5 @@ metric_time__day revenue_all_time trailing_2_months_revenue -0 2020-03-31 8000 3000 +0 2020-03-31 8000 7000 1 2020-04-01 8000 3000 2 2020-04-02 12000 7000 3 2020-04-03 12000 7000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_grain_to_date_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_grain_to_date_cumulative_metric__query_output.txt index 19b53d70d1..b5214d2035 100644 --- a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_grain_to_date_cumulative_metric__query_output.txt +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_grain_to_date_cumulative_metric__query_output.txt @@ -1,5 +1,5 @@ metric_time__day revenue_mtd -0 2021-01-03 1000 -1 2021-01-04 2000 -2 2021-01-05 2000 -3 2021-01-06 2000 +0 2021-01-03 3000 +1 2021-01-04 4000 +2 2021-01-05 4000 +3 2021-01-06 4000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_multiple_cumulative_metrics__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_multiple_cumulative_metrics__query_output.txt index 57e10f784b..43f215f1ee 100644 --- a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_multiple_cumulative_metrics__query_output.txt +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Postgres/test_multiple_cumulative_metrics__query_output.txt @@ -1,5 +1,5 @@ metric_time__day revenue_all_time trailing_2_months_revenue -0 2020-03-31 8000 3000 +0 2020-03-31 8000 7000 1 2020-04-01 8000 3000 2 2020-04-02 12000 7000 3 2020-04-03 12000 7000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_grain_to_date_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_grain_to_date_cumulative_metric__query_output.txt index 68984bb861..737fe3f4ca 100644 --- a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_grain_to_date_cumulative_metric__query_output.txt +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_grain_to_date_cumulative_metric__query_output.txt @@ -1,5 +1,5 @@ metric_time__day revenue_mtd -0 2021-01-03 1000 -1 2021-01-04 2000 -2 2021-01-05 2000 -3 2021-01-06 2000 +0 2021-01-03 3000 +1 2021-01-04 4000 +2 2021-01-05 4000 +3 2021-01-06 4000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_multiple_cumulative_metrics__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_multiple_cumulative_metrics__query_output.txt index 018d8d3c50..00ddadd8bd 100644 --- a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_multiple_cumulative_metrics__query_output.txt +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Redshift/test_multiple_cumulative_metrics__query_output.txt @@ -1,5 +1,5 @@ metric_time__day revenue_all_time trailing_2_months_revenue -0 2020-03-31 8000 3000 +0 2020-03-31 8000 7000 1 2020-04-01 8000 3000 2 2020-04-02 12000 7000 3 2020-04-03 12000 7000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_grain_to_date_cumulative_metric__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_grain_to_date_cumulative_metric__query_output.txt index 75de445e78..072298cd93 100644 --- a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_grain_to_date_cumulative_metric__query_output.txt +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_grain_to_date_cumulative_metric__query_output.txt @@ -1,5 +1,5 @@ METRIC_TIME__DAY REVENUE_MTD -0 2021-01-03 1000 -1 2021-01-04 2000 -2 2021-01-05 2000 -3 2021-01-06 2000 +0 2021-01-03 3000 +1 2021-01-04 4000 +2 2021-01-05 4000 +3 2021-01-06 4000 diff --git a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_multiple_cumulative_metrics__query_output.txt b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_multiple_cumulative_metrics__query_output.txt index d764f95899..c9bf660041 100644 --- a/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_multiple_cumulative_metrics__query_output.txt +++ b/metricflow/test/snapshots/test_cumulative_metrics.py/str/Snowflake/test_multiple_cumulative_metrics__query_output.txt @@ -1,5 +1,5 @@ METRIC_TIME__DAY REVENUE_ALL_TIME TRAILING_2_MONTHS_REVENUE -0 2020-03-31 8000 3000 +0 2020-03-31 8000 7000 1 2020-04-01 8000 3000 2 2020-04-02 12000 7000 3 2020-04-03 12000 7000