diff --git a/metricflow/test/dataflow/builder/test_dataflow_plan_builder.py b/metricflow/test/dataflow/builder/test_dataflow_plan_builder.py index ed1426d869..3b102f644d 100644 --- a/metricflow/test/dataflow/builder/test_dataflow_plan_builder.py +++ b/metricflow/test/dataflow/builder/test_dataflow_plan_builder.py @@ -462,7 +462,7 @@ def test_cumulative_metric_with_window( # noqa: D MetricFlowQuerySpec( metric_specs=(MetricSpec(element_name="trailing_2_months_revenue"),), dimension_specs=(), - time_dimension_specs=(MTD_SPEC_MONTH,), + time_dimension_specs=(MTD_SPEC_DAY,), ) ) diff --git a/metricflow/test/query_rendering/test_cumulative_metric_rendering.py b/metricflow/test/query_rendering/test_cumulative_metric_rendering.py index d3e887078b..f2bf7d50f4 100644 --- a/metricflow/test/query_rendering/test_cumulative_metric_rendering.py +++ b/metricflow/test/query_rendering/test_cumulative_metric_rendering.py @@ -43,7 +43,7 @@ def test_cumulative_metric( TimeDimensionSpec( element_name="ds", entity_links=(), - time_granularity=TimeGranularity.MONTH, + time_granularity=TimeGranularity.DAY, ), ), ) @@ -81,7 +81,7 @@ def test_cumulative_metric_with_time_constraint( TimeDimensionSpec( element_name="metric_time", entity_links=(), - time_granularity=TimeGranularity.MONTH, + time_granularity=TimeGranularity.DAY, ), ), time_range_constraint=TimeRangeConstraint( diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0.sql index 555dc9650e..f8b095a9f4 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0.sql @@ -1,16 +1,16 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__month + subq_3.ds__day , subq_3.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_2.ds__month + subq_2.ds__day , SUM(subq_2.txn_revenue) AS txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'ds__month'] + -- Pass Only Elements: ['txn_revenue', 'ds__day'] SELECT - subq_1.ds__month + subq_1.ds__day , subq_1.txn_revenue FROM ( -- Metric Time Dimension 'ds' @@ -84,5 +84,5 @@ FROM ( ) subq_1 ) subq_2 GROUP BY - ds__month + ds__day ) subq_3 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0_optimized.sql index 18340eb2b1..2324fc7d69 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0_optimized.sql @@ -1,11 +1,11 @@ -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' --- Pass Only Elements: ['txn_revenue', 'ds__month'] +-- Pass Only Elements: ['txn_revenue', 'ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC(created_at, month) AS ds__month + DATE_TRUNC(created_at, day) AS ds__day , SUM(revenue) AS trailing_2_months_revenue FROM ***************************.fct_revenue revenue_src_10007 GROUP BY - ds__month + ds__day 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 78365e1dbb..6a6e8ed83c 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 @@ -1,21 +1,21 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month + subq_8.metric_time__day , subq_8.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month + subq_7.metric_time__day , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_6.metric_time__month + subq_6.metric_time__day , subq_6.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__month'] + -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT - subq_5.metric_time__month + subq_5.metric_time__day , subq_5.txn_revenue FROM ( -- Join Self Over Time Range @@ -182,8 +182,8 @@ FROM ( ) ) subq_5 ) subq_6 - WHERE subq_6.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_7 GROUP BY - metric_time__month + metric_time__day ) subq_8 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 1e1d07a87c..90f636677b 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 @@ -1,10 +1,10 @@ -- Join Self Over Time Range --- Pass Only Elements: ['txn_revenue', 'metric_time__month'] +-- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.metric_time__month AS metric_time__month + subq_12.metric_time__day AS metric_time__day , SUM(subq_11.txn_revenue) AS trailing_2_months_revenue FROM ( -- Time Spine @@ -19,7 +19,6 @@ INNER JOIN ( -- 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_10007 WHERE DATE_TRUNC(created_at, day) BETWEEN '2019-11-01' AND '2020-01-01' @@ -30,6 +29,6 @@ ON ) AND ( subq_11.metric_time__day > DATE_SUB(CAST(subq_12.metric_time__day AS DATETIME), INTERVAL 2 month) ) -WHERE subq_11.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' +WHERE subq_12.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - metric_time__month + metric_time__day diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0.sql index b3590d74a0..437c78467a 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0.sql @@ -1,16 +1,16 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__month + subq_3.ds__day , subq_3.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_2.ds__month + subq_2.ds__day , SUM(subq_2.txn_revenue) AS txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'ds__month'] + -- Pass Only Elements: ['txn_revenue', 'ds__day'] SELECT - subq_1.ds__month + subq_1.ds__day , subq_1.txn_revenue FROM ( -- Metric Time Dimension 'ds' @@ -84,5 +84,5 @@ FROM ( ) subq_1 ) subq_2 GROUP BY - subq_2.ds__month + subq_2.ds__day ) subq_3 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0_optimized.sql index b50672640f..8c24543160 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0_optimized.sql @@ -1,11 +1,11 @@ -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' --- Pass Only Elements: ['txn_revenue', 'ds__month'] +-- Pass Only Elements: ['txn_revenue', 'ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('month', created_at) AS ds__month + DATE_TRUNC('day', created_at) AS ds__day , SUM(revenue) AS trailing_2_months_revenue FROM ***************************.fct_revenue revenue_src_10007 GROUP BY - DATE_TRUNC('month', created_at) + DATE_TRUNC('day', created_at) 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 38870197e4..4faccf1d37 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 @@ -1,21 +1,21 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month + subq_8.metric_time__day , subq_8.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month + subq_7.metric_time__day , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_6.metric_time__month + subq_6.metric_time__day , subq_6.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__month'] + -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT - subq_5.metric_time__month + subq_5.metric_time__day , subq_5.txn_revenue FROM ( -- Join Self Over Time Range @@ -182,8 +182,8 @@ FROM ( ) ) subq_5 ) subq_6 - WHERE subq_6.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_7 GROUP BY - subq_7.metric_time__month + subq_7.metric_time__day ) subq_8 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 933797f685..ddcc18a49f 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 @@ -1,10 +1,10 @@ -- Join Self Over Time Range --- Pass Only Elements: ['txn_revenue', 'metric_time__month'] +-- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.metric_time__month AS metric_time__month + subq_12.metric_time__day AS metric_time__day , SUM(subq_11.txn_revenue) AS trailing_2_months_revenue FROM ( -- Time Spine @@ -19,7 +19,6 @@ INNER JOIN ( -- 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_10007 WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' @@ -30,6 +29,6 @@ ON ) AND ( subq_11.metric_time__day > subq_12.metric_time__day - INTERVAL 2 month ) -WHERE subq_11.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' +WHERE subq_12.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - subq_11.metric_time__month + subq_12.metric_time__day diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0.sql index 2cd018a8ec..69a0bef50b 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0.sql @@ -1,16 +1,16 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__month + subq_3.ds__day , subq_3.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_2.ds__month + subq_2.ds__day , SUM(subq_2.txn_revenue) AS txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'ds__month'] + -- Pass Only Elements: ['txn_revenue', 'ds__day'] SELECT - subq_1.ds__month + subq_1.ds__day , subq_1.txn_revenue FROM ( -- Metric Time Dimension 'ds' @@ -84,5 +84,5 @@ FROM ( ) subq_1 ) subq_2 GROUP BY - subq_2.ds__month + subq_2.ds__day ) subq_3 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0_optimized.sql index b50672640f..8c24543160 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0_optimized.sql @@ -1,11 +1,11 @@ -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' --- Pass Only Elements: ['txn_revenue', 'ds__month'] +-- Pass Only Elements: ['txn_revenue', 'ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('month', created_at) AS ds__month + DATE_TRUNC('day', created_at) AS ds__day , SUM(revenue) AS trailing_2_months_revenue FROM ***************************.fct_revenue revenue_src_10007 GROUP BY - DATE_TRUNC('month', created_at) + DATE_TRUNC('day', created_at) 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 53baa7bf24..fc6fe5b93b 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 @@ -1,21 +1,21 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month + subq_8.metric_time__day , subq_8.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month + subq_7.metric_time__day , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_6.metric_time__month + subq_6.metric_time__day , subq_6.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__month'] + -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT - subq_5.metric_time__month + subq_5.metric_time__day , subq_5.txn_revenue FROM ( -- Join Self Over Time Range @@ -182,8 +182,8 @@ FROM ( ) ) subq_5 ) subq_6 - WHERE subq_6.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_7 GROUP BY - subq_7.metric_time__month + subq_7.metric_time__day ) subq_8 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 db122dc378..221b874d52 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 @@ -1,10 +1,10 @@ -- Join Self Over Time Range --- Pass Only Elements: ['txn_revenue', 'metric_time__month'] +-- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.metric_time__month AS metric_time__month + subq_12.metric_time__day AS metric_time__day , SUM(subq_11.txn_revenue) AS trailing_2_months_revenue FROM ( -- Time Spine @@ -19,7 +19,6 @@ INNER JOIN ( -- 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_10007 WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' @@ -30,6 +29,6 @@ ON ) AND ( subq_11.metric_time__day > DATEADD(month, -2, subq_12.metric_time__day) ) -WHERE subq_11.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' +WHERE subq_12.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - subq_11.metric_time__month + subq_12.metric_time__day diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0.sql index c1bcc772c5..fd869b7516 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0.sql @@ -1,16 +1,16 @@ -- Compute Metrics via Expressions SELECT - subq_3.ds__month + subq_3.ds__day , subq_3.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_2.ds__month + subq_2.ds__day , SUM(subq_2.txn_revenue) AS txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'ds__month'] + -- Pass Only Elements: ['txn_revenue', 'ds__day'] SELECT - subq_1.ds__month + subq_1.ds__day , subq_1.txn_revenue FROM ( -- Metric Time Dimension 'ds' @@ -84,5 +84,5 @@ FROM ( ) subq_1 ) subq_2 GROUP BY - subq_2.ds__month + subq_2.ds__day ) subq_3 diff --git a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0_optimized.sql index b50672640f..8c24543160 100644 --- a/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0_optimized.sql @@ -1,11 +1,11 @@ -- Read Elements From Semantic Model 'revenue' -- Metric Time Dimension 'ds' --- Pass Only Elements: ['txn_revenue', 'ds__month'] +-- Pass Only Elements: ['txn_revenue', 'ds__day'] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('month', created_at) AS ds__month + DATE_TRUNC('day', created_at) AS ds__day , SUM(revenue) AS trailing_2_months_revenue FROM ***************************.fct_revenue revenue_src_10007 GROUP BY - DATE_TRUNC('month', created_at) + DATE_TRUNC('day', created_at) 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 287b5535b0..d65dd4a5ae 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 @@ -1,21 +1,21 @@ -- Compute Metrics via Expressions SELECT - subq_8.metric_time__month + subq_8.metric_time__day , subq_8.txn_revenue AS trailing_2_months_revenue FROM ( -- Aggregate Measures SELECT - subq_7.metric_time__month + subq_7.metric_time__day , SUM(subq_7.txn_revenue) AS txn_revenue FROM ( -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] SELECT - subq_6.metric_time__month + subq_6.metric_time__day , subq_6.txn_revenue FROM ( - -- Pass Only Elements: ['txn_revenue', 'metric_time__month'] + -- Pass Only Elements: ['txn_revenue', 'metric_time__day'] SELECT - subq_5.metric_time__month + subq_5.metric_time__day , subq_5.txn_revenue FROM ( -- Join Self Over Time Range @@ -182,8 +182,8 @@ FROM ( ) ) subq_5 ) subq_6 - WHERE subq_6.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' + WHERE subq_6.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' ) subq_7 GROUP BY - subq_7.metric_time__month + subq_7.metric_time__day ) subq_8 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 db122dc378..221b874d52 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 @@ -1,10 +1,10 @@ -- Join Self Over Time Range --- Pass Only Elements: ['txn_revenue', 'metric_time__month'] +-- Pass Only Elements: ['txn_revenue', 'metric_time__day'] -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-01T00:00:00] -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.metric_time__month AS metric_time__month + subq_12.metric_time__day AS metric_time__day , SUM(subq_11.txn_revenue) AS trailing_2_months_revenue FROM ( -- Time Spine @@ -19,7 +19,6 @@ INNER JOIN ( -- 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_10007 WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-11-01' AND '2020-01-01' @@ -30,6 +29,6 @@ ON ) AND ( subq_11.metric_time__day > DATEADD(month, -2, subq_12.metric_time__day) ) -WHERE subq_11.metric_time__month BETWEEN '2020-01-01' AND '2020-01-01' +WHERE subq_12.metric_time__day BETWEEN '2020-01-01' AND '2020-01-01' GROUP BY - subq_11.metric_time__month + subq_12.metric_time__day diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_cumulative_metric_with_window__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_cumulative_metric_with_window__dfp_0.xml index 2c5b9852e3..91b457cb5a 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_cumulative_metric_with_window__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_cumulative_metric_with_window__dfp_0.xml @@ -11,12 +11,12 @@ - + - - + +