Skip to content

Commit 7b15732

Browse files
authored
chore(tests): Prepare tests for custom time shifts with calendar cubes (#9770)
* Extend test schema / dataset with RetailCalendar * add tests for RetailCalendar * edit fixtures/excludes/etc * update snapshots
1 parent 89d3d37 commit 7b15732

17 files changed

+1509
-14
lines changed

packages/cubejs-testing-drivers/fixtures/_schemas.json

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,11 @@
258258
"name": "Customers",
259259
"relationship": "belongs_to",
260260
"sql": "{CUBE}.customer_id = {Customers}.customer_id"
261+
},
262+
{
263+
"name": "RetailCalendar",
264+
"relationship": "many_to_one",
265+
"sql": "{CUBE}.order_date = {RetailCalendar.date_val}"
261266
}
262267
],
263268
"dimensions": [
@@ -389,6 +394,36 @@
389394
"type": "prior"
390395
}]
391396
},
397+
{
398+
"name": "totalCountRetailYearAgo",
399+
"type": "number",
400+
"sql": "{count}",
401+
"multi_stage": true,
402+
"time_shift": [{
403+
"interval": "1 year",
404+
"type": "prior"
405+
}]
406+
},
407+
{
408+
"name": "totalCountRetailMonthAgo",
409+
"type": "number",
410+
"sql": "{count}",
411+
"multi_stage": true,
412+
"time_shift": [{
413+
"interval": "1 month",
414+
"type": "prior"
415+
}]
416+
},
417+
{
418+
"name": "totalCountRetailWeekAgo",
419+
"type": "number",
420+
"sql": "{count}",
421+
"multi_stage": true,
422+
"time_shift": [{
423+
"interval": "1 week",
424+
"type": "prior"
425+
}]
426+
},
392427
{
393428
"name": "totalProfitForStatus",
394429
"type": "sum",
@@ -462,6 +497,55 @@
462497
}
463498
}
464499
]
500+
},
501+
{
502+
"name": "RetailCalendar",
503+
"calendar": true,
504+
"dimensions": [
505+
{
506+
"name": "date_val",
507+
"sql": "date_val",
508+
"type": "time",
509+
"primary_key": true,
510+
"shown": true
511+
},
512+
{
513+
"name": "retail_date",
514+
"sql": "date_val",
515+
"type": "time",
516+
"granularities": [
517+
{
518+
"name": "week",
519+
"sql": "{CUBE}.retail_week_begin_date"
520+
},
521+
{
522+
"name": "quarter",
523+
"sql": "{CUBE}.retail_quarter_begin_date"
524+
},
525+
{
526+
"name": "year",
527+
"sql": "{CUBE}.retail_year_begin_date"
528+
}
529+
],
530+
"timeShift": [
531+
{
532+
"interval": "1 month",
533+
"type": "prior",
534+
"sql": "{CUBE}.retail_date_prev_month"
535+
},
536+
{
537+
"interval": "1 quarter",
538+
"type": "prior",
539+
"sql": "{CUBE}.retail_date_prev_quarter"
540+
},
541+
{
542+
"interval": "1 year",
543+
"type": "prior",
544+
"sql": "{CUBE}.retail_date_prev_year"
545+
}
546+
]
547+
}
548+
]
465549
}
466550
]
467551
}

packages/cubejs-testing-drivers/fixtures/athena.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"products": "products",
3535
"customers": "customers",
3636
"ecommerce": "ecommerce",
37-
"bigecommerce": "bigecommerce"
37+
"bigecommerce": "bigecommerce",
38+
"retailcalendar": "retailcalendar"
3839
},
3940
"preAggregations": {
4041
"Products": [],
@@ -150,6 +151,9 @@
150151
"week granularity is not supported for intervals",
151152
"querying BigECommerce: rolling window by 2 week",
152153
"querying custom granularities ECommerce: count by two_mo_by_feb + no dimension + rollingCountByLeading without date range",
154+
"querying BigECommerce with Retail Calendar: totalCountRetailYearAgo",
155+
"querying BigECommerce with Retail Calendar: totalCountRetailMonthAgo",
156+
"querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo",
153157

154158
"---------------------------------------",
155159
"Custom Granularities ",
@@ -203,6 +207,7 @@
203207
"querying BigECommerce: rolling window YTD (month + week + no gran)",
204208
"querying BigECommerce: rolling window YTD without granularity",
205209
"SQL API: Rolling Window YTD (year + month + day + date_trunc equal)",
206-
"SQL API: Rolling Window YTD (year + month + day + date_trunc IN)"
210+
"SQL API: Rolling Window YTD (year + month + day + date_trunc IN)",
211+
"querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo"
207212
]
208213
}

packages/cubejs-testing-drivers/fixtures/bigquery.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"products": "test.products",
3737
"customers": "test.customers",
3838
"ecommerce": "test.ecommerce",
39-
"bigecommerce": "test.bigecommerce"
39+
"bigecommerce": "test.bigecommerce",
40+
"retailcalendar": "test.retailcalendar"
4041
},
4142
"preAggregations": {
4243
"Products": [],
@@ -164,6 +165,9 @@
164165
"querying BigECommerce: rolling window by 2 month without date range",
165166
"querying BigECommerce: rolling window YTD without date range",
166167
"querying custom granularities ECommerce: count by two_mo_by_feb + no dimension + rollingCountByLeading without date range",
168+
"querying BigECommerce with Retail Calendar: totalCountRetailYearAgo",
169+
"querying BigECommerce with Retail Calendar: totalCountRetailMonthAgo",
170+
"querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo",
167171

168172
"---------------------------------------",
169173
"SKIPPED SQL API (Need work)",

packages/cubejs-testing-drivers/fixtures/clickhouse.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@
7474
"products": "products",
7575
"customers": "customers",
7676
"ecommerce": "ecommerce",
77-
"bigecommerce": "bigecommerce"
77+
"bigecommerce": "bigecommerce",
78+
"retailcalendar": "retailcalendar"
7879
},
7980
"preAggregations": {
8081
"Products": [],
@@ -201,6 +202,9 @@
201202
"querying BigECommerce: rolling window by 2 month without date range",
202203
"querying BigECommerce: rolling window YTD without date range",
203204
"querying custom granularities ECommerce: count by two_mo_by_feb + no dimension + rollingCountByLeading without date range",
205+
"querying BigECommerce with Retail Calendar: totalCountRetailYearAgo",
206+
"querying BigECommerce with Retail Calendar: totalCountRetailMonthAgo",
207+
"querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo",
204208

205209
"---------------------------------------",
206210
"Custom Granularities ",

packages/cubejs-testing-drivers/fixtures/databricks-jdbc.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@
9696
"products": "products",
9797
"customers": "customers",
9898
"ecommerce": "ecommerce",
99-
"bigecommerce": "bigecommerce"
99+
"bigecommerce": "bigecommerce",
100+
"retailcalendar": "retailcalendar"
100101
},
101102
"preAggregations": {
102103
"Products": [],
@@ -217,6 +218,9 @@
217218
"querying BigECommerce: rolling window by 2 month without date range",
218219
"querying BigECommerce: rolling window YTD without date range",
219220
"querying custom granularities ECommerce: count by two_mo_by_feb + no dimension + rollingCountByLeading without date range",
221+
"querying BigECommerce with Retail Calendar: totalCountRetailYearAgo",
222+
"querying BigECommerce with Retail Calendar: totalCountRetailMonthAgo",
223+
"querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo",
220224

221225
"---------------------------------------",
222226
"Custom Granularities ",

packages/cubejs-testing-drivers/fixtures/mssql.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
"products": "products",
4444
"customers": "customers",
4545
"ecommerce": "ecommerce",
46-
"bigecommerce": "bigecommerce"
46+
"bigecommerce": "bigecommerce",
47+
"retailcalendar": "retailcalendar"
4748
},
4849
"preAggregations": {
4950
"Products": [],
@@ -143,6 +144,9 @@
143144
"querying BigECommerce: rolling window by 2 month without date range",
144145
"querying BigECommerce: rolling window YTD without date range",
145146
"querying custom granularities ECommerce: count by two_mo_by_feb + no dimension + rollingCountByLeading without date range",
147+
"querying BigECommerce with Retail Calendar: totalCountRetailYearAgo",
148+
"querying BigECommerce with Retail Calendar: totalCountRetailMonthAgo",
149+
"querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo",
146150

147151
"---------------------------------------",
148152
"SKIPPED SQL API (Need work)",

packages/cubejs-testing-drivers/fixtures/mysql.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
"products": "products",
4444
"customers": "customers",
4545
"ecommerce": "ecommerce",
46-
"bigecommerce": "bigecommerce"
46+
"bigecommerce": "bigecommerce",
47+
"retailcalendar": "retailcalendar"
4748
},
4849
"preAggregations": {
4950
"Products": [],
@@ -139,6 +140,9 @@
139140
"querying BigECommerce: rolling window by 2 month without date range",
140141
"querying BigECommerce: rolling window YTD without date range",
141142
"querying custom granularities ECommerce: count by two_mo_by_feb + no dimension + rollingCountByLeading without date range",
143+
"querying BigECommerce with Retail Calendar: totalCountRetailYearAgo",
144+
"querying BigECommerce with Retail Calendar: totalCountRetailMonthAgo",
145+
"querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo",
142146

143147
"---------------------------------------",
144148
"Custom Granularities ",

packages/cubejs-testing-drivers/fixtures/postgres.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
"products": "products",
4343
"customers": "customers",
4444
"ecommerce": "ecommerce",
45-
"bigecommerce": "bigecommerce"
45+
"bigecommerce": "bigecommerce",
46+
"retailcalendar": "retailcalendar"
4647
},
4748
"preAggregations": {
4849
"Products": [],
@@ -163,7 +164,10 @@
163164
"querying BigECommerce: rolling window by 2 day without date range",
164165
"querying BigECommerce: rolling window by 2 month without date range",
165166
"querying BigECommerce: rolling window YTD without date range",
166-
"querying custom granularities ECommerce: count by two_mo_by_feb + no dimension + rollingCountByLeading without date range"
167+
"querying custom granularities ECommerce: count by two_mo_by_feb + no dimension + rollingCountByLeading without date range",
168+
"querying BigECommerce with Retail Calendar: totalCountRetailYearAgo",
169+
"querying BigECommerce with Retail Calendar: totalCountRetailMonthAgo",
170+
"querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo"
167171
],
168172
"tesseractSkip": [
169173
"querying Products: dimensions -- doesn't work wo ordering",

packages/cubejs-testing-drivers/fixtures/redshift.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
"products": "public.products",
4848
"customers": "public.customers",
4949
"ecommerce": "public.ecommerce",
50-
"bigecommerce": "public.bigecommerce"
50+
"bigecommerce": "public.bigecommerce",
51+
"retailcalendar": "public.retailcalendar"
5152
},
5253
"preAggregations": {
5354
"Products": [],
@@ -175,6 +176,9 @@
175176
"querying BigECommerce: rolling window by 2 month without date range",
176177
"querying BigECommerce: rolling window YTD without date range",
177178
"querying custom granularities ECommerce: count by two_mo_by_feb + no dimension + rollingCountByLeading without date range",
179+
"querying BigECommerce with Retail Calendar: totalCountRetailYearAgo",
180+
"querying BigECommerce with Retail Calendar: totalCountRetailMonthAgo",
181+
"querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo",
178182

179183
"---------------------------------------",
180184
"SKIPPED SQL API (Need work) ",

packages/cubejs-testing-drivers/fixtures/snowflake.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@
120120
"products": "public.products",
121121
"customers": "public.customers",
122122
"ecommerce": "public.ecommerce",
123-
"bigecommerce": "public.bigecommerce"
123+
"bigecommerce": "public.bigecommerce",
124+
"retailcalendar": "public.retailcalendar"
124125
},
125126
"preAggregations": {
126127
"Products": [],
@@ -239,6 +240,9 @@
239240
"---------------------------------------",
240241
"querying BigECommerce: rolling window by 2 day without date range",
241242
"querying BigECommerce: rolling window by 2 month without date range",
242-
"querying BigECommerce: rolling window YTD without date range"
243+
"querying BigECommerce: rolling window YTD without date range",
244+
"querying BigECommerce with Retail Calendar: totalCountRetailYearAgo",
245+
"querying BigECommerce with Retail Calendar: totalCountRetailMonthAgo",
246+
"querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo"
243247
]
244248
}

0 commit comments

Comments
 (0)