-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SQL rendering tests for custom grain in where filters
- Loading branch information
1 parent
5ff504b
commit 59d9c6c
Showing
9 changed files
with
934 additions
and
0 deletions.
There are no files selected for viewing
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
134 changes: 134 additions & 0 deletions
134
...nularity.py/SqlQueryPlan/DuckDB/test_no_metrics_with_custom_granularity_filter__plan0.sql
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,134 @@ | ||
-- Pass Only Elements: ['listing__ds__day',] | ||
SELECT | ||
subq_2.listing__ds__day | ||
FROM ( | ||
-- Constrain Output with WHERE | ||
SELECT | ||
subq_1.listing__ds__martian_day | ||
, subq_1.ds__day | ||
, subq_1.ds__week | ||
, subq_1.ds__month | ||
, subq_1.ds__quarter | ||
, subq_1.ds__year | ||
, subq_1.ds__extract_year | ||
, subq_1.ds__extract_quarter | ||
, subq_1.ds__extract_month | ||
, subq_1.ds__extract_day | ||
, subq_1.ds__extract_dow | ||
, subq_1.ds__extract_doy | ||
, subq_1.created_at__day | ||
, subq_1.created_at__week | ||
, subq_1.created_at__month | ||
, subq_1.created_at__quarter | ||
, subq_1.created_at__year | ||
, subq_1.created_at__extract_year | ||
, subq_1.created_at__extract_quarter | ||
, subq_1.created_at__extract_month | ||
, subq_1.created_at__extract_day | ||
, subq_1.created_at__extract_dow | ||
, subq_1.created_at__extract_doy | ||
, subq_1.listing__ds__day | ||
, subq_1.listing__ds__week | ||
, subq_1.listing__ds__month | ||
, subq_1.listing__ds__quarter | ||
, subq_1.listing__ds__year | ||
, subq_1.listing__ds__extract_year | ||
, subq_1.listing__ds__extract_quarter | ||
, subq_1.listing__ds__extract_month | ||
, subq_1.listing__ds__extract_day | ||
, subq_1.listing__ds__extract_dow | ||
, subq_1.listing__ds__extract_doy | ||
, subq_1.listing__created_at__day | ||
, subq_1.listing__created_at__week | ||
, subq_1.listing__created_at__month | ||
, subq_1.listing__created_at__quarter | ||
, subq_1.listing__created_at__year | ||
, subq_1.listing__created_at__extract_year | ||
, subq_1.listing__created_at__extract_quarter | ||
, subq_1.listing__created_at__extract_month | ||
, subq_1.listing__created_at__extract_day | ||
, subq_1.listing__created_at__extract_dow | ||
, subq_1.listing__created_at__extract_doy | ||
, subq_1.listing | ||
, subq_1.user | ||
, subq_1.listing__user | ||
, subq_1.country_latest | ||
, subq_1.is_lux_latest | ||
, subq_1.capacity_latest | ||
, subq_1.listing__country_latest | ||
, subq_1.listing__is_lux_latest | ||
, subq_1.listing__capacity_latest | ||
, subq_1.listings | ||
, subq_1.largest_listing | ||
, subq_1.smallest_listing | ||
FROM ( | ||
-- Read Elements From Semantic Model 'listings_latest' | ||
-- Join to Custom Granularity Dataset | ||
SELECT | ||
1 AS listings | ||
, listings_latest_src_28000.capacity AS largest_listing | ||
, listings_latest_src_28000.capacity AS smallest_listing | ||
, DATE_TRUNC('day', listings_latest_src_28000.created_at) AS ds__day | ||
, DATE_TRUNC('week', listings_latest_src_28000.created_at) AS ds__week | ||
, DATE_TRUNC('month', listings_latest_src_28000.created_at) AS ds__month | ||
, DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS ds__quarter | ||
, DATE_TRUNC('year', listings_latest_src_28000.created_at) AS ds__year | ||
, EXTRACT(year FROM listings_latest_src_28000.created_at) AS ds__extract_year | ||
, EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS ds__extract_quarter | ||
, EXTRACT(month FROM listings_latest_src_28000.created_at) AS ds__extract_month | ||
, EXTRACT(day FROM listings_latest_src_28000.created_at) AS ds__extract_day | ||
, EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS ds__extract_dow | ||
, EXTRACT(doy FROM listings_latest_src_28000.created_at) AS ds__extract_doy | ||
, DATE_TRUNC('day', listings_latest_src_28000.created_at) AS created_at__day | ||
, DATE_TRUNC('week', listings_latest_src_28000.created_at) AS created_at__week | ||
, DATE_TRUNC('month', listings_latest_src_28000.created_at) AS created_at__month | ||
, DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS created_at__quarter | ||
, DATE_TRUNC('year', listings_latest_src_28000.created_at) AS created_at__year | ||
, EXTRACT(year FROM listings_latest_src_28000.created_at) AS created_at__extract_year | ||
, EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS created_at__extract_quarter | ||
, EXTRACT(month FROM listings_latest_src_28000.created_at) AS created_at__extract_month | ||
, EXTRACT(day FROM listings_latest_src_28000.created_at) AS created_at__extract_day | ||
, EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS created_at__extract_dow | ||
, EXTRACT(doy FROM listings_latest_src_28000.created_at) AS created_at__extract_doy | ||
, listings_latest_src_28000.country AS country_latest | ||
, listings_latest_src_28000.is_lux AS is_lux_latest | ||
, listings_latest_src_28000.capacity AS capacity_latest | ||
, DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day | ||
, DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__ds__week | ||
, DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__ds__month | ||
, DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__ds__quarter | ||
, DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__ds__year | ||
, EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__ds__extract_year | ||
, EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__ds__extract_quarter | ||
, EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__ds__extract_month | ||
, EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__ds__extract_day | ||
, EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__ds__extract_dow | ||
, EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__ds__extract_doy | ||
, DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__created_at__day | ||
, DATE_TRUNC('week', listings_latest_src_28000.created_at) AS listing__created_at__week | ||
, DATE_TRUNC('month', listings_latest_src_28000.created_at) AS listing__created_at__month | ||
, DATE_TRUNC('quarter', listings_latest_src_28000.created_at) AS listing__created_at__quarter | ||
, DATE_TRUNC('year', listings_latest_src_28000.created_at) AS listing__created_at__year | ||
, EXTRACT(year FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_year | ||
, EXTRACT(quarter FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_quarter | ||
, EXTRACT(month FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_month | ||
, EXTRACT(day FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_day | ||
, EXTRACT(isodow FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_dow | ||
, EXTRACT(doy FROM listings_latest_src_28000.created_at) AS listing__created_at__extract_doy | ||
, listings_latest_src_28000.country AS listing__country_latest | ||
, listings_latest_src_28000.is_lux AS listing__is_lux_latest | ||
, listings_latest_src_28000.capacity AS listing__capacity_latest | ||
, listings_latest_src_28000.listing_id AS listing | ||
, listings_latest_src_28000.user_id AS user | ||
, listings_latest_src_28000.user_id AS listing__user | ||
, subq_0.martian_day AS listing__ds__martian_day | ||
FROM ***************************.dim_listings_latest listings_latest_src_28000 | ||
LEFT OUTER JOIN | ||
***************************.mf_time_spine subq_0 | ||
ON | ||
DATE_TRUNC('day', listings_latest_src_28000.created_at) = subq_0.ds | ||
) subq_1 | ||
WHERE listing__ds__martian_day = '2020-01-01' | ||
) subq_2 | ||
GROUP BY | ||
subq_2.listing__ds__day |
19 changes: 19 additions & 0 deletions
19
...y/SqlQueryPlan/DuckDB/test_no_metrics_with_custom_granularity_filter__plan0_optimized.sql
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,19 @@ | ||
-- Constrain Output with WHERE | ||
-- Pass Only Elements: ['listing__ds__day',] | ||
SELECT | ||
listing__ds__day | ||
FROM ( | ||
-- Read Elements From Semantic Model 'listings_latest' | ||
-- Join to Custom Granularity Dataset | ||
SELECT | ||
DATE_TRUNC('day', listings_latest_src_28000.created_at) AS listing__ds__day | ||
, subq_3.martian_day AS listing__ds__martian_day | ||
FROM ***************************.dim_listings_latest listings_latest_src_28000 | ||
LEFT OUTER JOIN | ||
***************************.mf_time_spine subq_3 | ||
ON | ||
DATE_TRUNC('day', listings_latest_src_28000.created_at) = subq_3.ds | ||
) subq_4 | ||
WHERE listing__ds__martian_day = '2020-01-01' | ||
GROUP BY | ||
listing__ds__day |
Oops, something went wrong.