@@ -9,7 +9,24 @@ describe('Pre Aggregation by filter match tests', () => {
99
1010 cube . dimensions . created = {
1111 sql : 'created' ,
12- type : 'time'
12+ type : 'time' ,
13+ granularities : {
14+ one_week : {
15+ interval : '1 week' ,
16+ } ,
17+ one_week_by_sunday : {
18+ interval : '1 week' ,
19+ offset : '-1 day'
20+ } ,
21+ two_weeks_by_1st_feb_00am : {
22+ interval : '2 weeks' ,
23+ origin : '2024-02-01 00:00:00'
24+ } ,
25+ two_weeks_by_1st_feb_10am : {
26+ interval : '2 weeks' ,
27+ origin : '2024-02-01 10:00:00'
28+ }
29+ }
1330 } ;
1431
1532 return prepareCube ( 'cube' , cube ) ;
@@ -20,6 +37,7 @@ describe('Pre Aggregation by filter match tests', () => {
2037 measures : Array < String > ,
2138 preAggTimeGranularity : string ,
2239 queryAggTimeGranularity : string ,
40+ queryTimeZone : string = 'America/Los_Angeles' ,
2341 ) {
2442 const aaa : any = {
2543 type : 'rollup' ,
@@ -28,6 +46,8 @@ describe('Pre Aggregation by filter match tests', () => {
2846 timeDimension : 'cube.created' ,
2947 granularity : preAggTimeGranularity ,
3048 partitionGranularity : 'year' ,
49+ // Enabling only for custom granularities
50+ allowNonStrictDateRangeMatch : ! / ^ ( m i n u t e | h o u r | d a y | w e e k | m o n t h | q u a r t e r | y e a r ) $ / . test ( preAggTimeGranularity )
3151 } ;
3252
3353 const cube : any = {
@@ -55,7 +75,7 @@ describe('Pre Aggregation by filter match tests', () => {
5575 granularity : queryAggTimeGranularity ,
5676 dateRange : { from : '2017-01-01' , to : '2017-03-31' }
5777 } ] ,
58- timezone : 'America/Los_Angeles' ,
78+ timezone : queryTimeZone ,
5979 } ) ;
6080
6181 const usePreAggregation = PreAggregations . canUsePreAggregationForTransformedQueryFn (
@@ -71,6 +91,26 @@ describe('Pre Aggregation by filter match tests', () => {
7191 true , [ 'count' ] , 'day' , 'day'
7292 ) ) ;
7393
94+ it ( '1 count measure, one_week_by_sunday, one_week_by_sunday' , ( ) => testPreAggregationMatch (
95+ true , [ 'count' ] , 'one_week_by_sunday' , 'one_week_by_sunday'
96+ ) ) ;
97+
98+ it ( '1 count measure, two_weeks_by_1st_feb_00am, two_weeks_by_1st_feb_00am' , ( ) => testPreAggregationMatch (
99+ true , [ 'count' ] , 'two_weeks_by_1st_feb_00am' , 'two_weeks_by_1st_feb_00am'
100+ ) ) ;
101+
102+ it ( '1 count measure, day, one_week_by_sunday' , ( ) => testPreAggregationMatch (
103+ true , [ 'count' ] , 'day' , 'one_week_by_sunday'
104+ ) ) ;
105+
106+ it ( '1 count measure, day, two_weeks_by_1st_feb_00am' , ( ) => testPreAggregationMatch (
107+ true , [ 'count' ] , 'day' , 'two_weeks_by_1st_feb_00am'
108+ ) ) ;
109+
110+ it ( '1 count measure, day, two_weeks_by_1st_feb_10am' , ( ) => testPreAggregationMatch (
111+ false , [ 'count' ] , 'day' , 'two_weeks_by_1st_feb_10am'
112+ ) ) ;
113+
74114 it ( '1 count measure, week, day' , ( ) => testPreAggregationMatch (
75115 false , [ 'count' ] , 'week' , 'day'
76116 ) ) ;
0 commit comments