-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
132 additions
and
0 deletions.
There are no files selected for viewing
132 changes: 132 additions & 0 deletions
132
tests_metricflow/snapshots/test_explain.py/str/test_optimization_level__result.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |