From 2ba107f20fc5f8ff33160a3fbc75d7171a31d7fd Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Wed, 11 Dec 2024 13:13:43 -0800 Subject: [PATCH] Update snapshots. --- .../str/test_optimization_level__result.txt | 132 ++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 tests_metricflow/snapshots/test_explain.py/str/test_optimization_level__result.txt diff --git a/tests_metricflow/snapshots/test_explain.py/str/test_optimization_level__result.txt b/tests_metricflow/snapshots/test_explain.py/str/test_optimization_level__result.txt new file mode 100644 index 000000000..41d719240 --- /dev/null +++ b/tests_metricflow/snapshots/test_explain.py/str/test_optimization_level__result.txt @@ -0,0 +1,132 @@ +test_name: test_optimization_level +test_filename: test_explain.py +docstring: + Tests that the results of explain reflect the SQL optimization level in the request. +expectation_description: + The result for SqlQueryOptimizationLevel.O5 should be SQL uses a CTE. +--- +O4: + WITH sma_10014_cte AS ( + SELECT + listing_id AS listing + , country AS country_latest + FROM ***************************.dim_listings_latest listings_latest_src_10000 + ) + + SELECT + COALESCE(subq_8.metric_time__day, subq_16.metric_time__day) AS metric_time__day + , COALESCE(subq_8.listing__country_latest, subq_16.listing__country_latest) AS listing__country_latest + , MAX(subq_8.bookings) AS bookings + , MAX(subq_16.views) AS views + FROM ( + SELECT + subq_1.metric_time__day AS metric_time__day + , sma_10014_cte.country_latest AS listing__country_latest + , SUM(subq_1.bookings) AS bookings + FROM ( + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , listing_id AS listing + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_10000 + ) subq_1 + LEFT OUTER JOIN + sma_10014_cte sma_10014_cte + ON + subq_1.listing = sma_10014_cte.listing + GROUP BY + subq_1.metric_time__day + , sma_10014_cte.country_latest + ) subq_8 + FULL OUTER JOIN ( + SELECT + subq_10.metric_time__day AS metric_time__day + , sma_10014_cte.country_latest AS listing__country_latest + , SUM(subq_10.views) AS views + FROM ( + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , listing_id AS listing + , 1 AS views + FROM ***************************.fct_views views_source_src_10000 + ) subq_10 + LEFT OUTER JOIN + sma_10014_cte sma_10014_cte + ON + subq_10.listing = sma_10014_cte.listing + GROUP BY + subq_10.metric_time__day + , sma_10014_cte.country_latest + ) subq_16 + ON + ( + subq_8.listing__country_latest = subq_16.listing__country_latest + ) AND ( + subq_8.metric_time__day = subq_16.metric_time__day + ) + GROUP BY + COALESCE(subq_8.metric_time__day, subq_16.metric_time__day) + , COALESCE(subq_8.listing__country_latest, subq_16.listing__country_latest) + +O5: + WITH sma_10014_cte AS ( + SELECT + listing_id AS listing + , country AS country_latest + FROM ***************************.dim_listings_latest listings_latest_src_10000 + ) + + SELECT + COALESCE(subq_8.metric_time__day, subq_16.metric_time__day) AS metric_time__day + , COALESCE(subq_8.listing__country_latest, subq_16.listing__country_latest) AS listing__country_latest + , MAX(subq_8.bookings) AS bookings + , MAX(subq_16.views) AS views + FROM ( + SELECT + subq_1.metric_time__day AS metric_time__day + , sma_10014_cte.country_latest AS listing__country_latest + , SUM(subq_1.bookings) AS bookings + FROM ( + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , listing_id AS listing + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_10000 + ) subq_1 + LEFT OUTER JOIN + sma_10014_cte sma_10014_cte + ON + subq_1.listing = sma_10014_cte.listing + GROUP BY + subq_1.metric_time__day + , sma_10014_cte.country_latest + ) subq_8 + FULL OUTER JOIN ( + SELECT + subq_10.metric_time__day AS metric_time__day + , sma_10014_cte.country_latest AS listing__country_latest + , SUM(subq_10.views) AS views + FROM ( + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , listing_id AS listing + , 1 AS views + FROM ***************************.fct_views views_source_src_10000 + ) subq_10 + LEFT OUTER JOIN + sma_10014_cte sma_10014_cte + ON + subq_10.listing = sma_10014_cte.listing + GROUP BY + subq_10.metric_time__day + , sma_10014_cte.country_latest + ) subq_16 + ON + ( + subq_8.listing__country_latest = subq_16.listing__country_latest + ) AND ( + subq_8.metric_time__day = subq_16.metric_time__day + ) + GROUP BY + COALESCE(subq_8.metric_time__day, subq_16.metric_time__day) + , COALESCE(subq_8.listing__country_latest, subq_16.listing__country_latest)