@@ -16,7 +16,8 @@ describe('Pre Aggregation by filter match tests', () => {
1616 } ,
1717 one_week_by_sunday : {
1818 interval : '1 week' ,
19- offset : '-1 day'
19+ // offset: '-1 day' // offsets might lead to flaky tests through years
20+ origin : '2025-01-05 00:00:00'
2021 } ,
2122 two_weeks_by_1st_feb_00am : {
2223 interval : '2 weeks' ,
@@ -38,6 +39,8 @@ describe('Pre Aggregation by filter match tests', () => {
3839 preAggTimeGranularity : string ,
3940 queryAggTimeGranularity : string ,
4041 queryTimeZone : string = 'America/Los_Angeles' ,
42+ dateRange : [ string , string ] = [ '2017-01-01' , '2017-03-31' ] ,
43+ allowNonStrictDateRangeMatch : boolean = false
4144 ) {
4245 const aaa : any = {
4346 type : 'rollup' ,
@@ -46,8 +49,7 @@ describe('Pre Aggregation by filter match tests', () => {
4649 timeDimension : 'cube.created' ,
4750 granularity : preAggTimeGranularity ,
4851 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 )
52+ allowNonStrictDateRangeMatch
5153 } ;
5254
5355 const cube : any = {
@@ -65,15 +67,15 @@ describe('Pre Aggregation by filter match tests', () => {
6567
6668 // aaa.sortedDimensions = aaa.dimensions;
6769 // aaa.sortedDimensions.sort();
68- aaa . sortedTimeDimensions = [ [ aaa . timeDimension , aaa . granularity ] ] ;
70+ aaa . sortedTimeDimensions = [ [ aaa . timeDimension , aaa . granularity , 'day' ] ] ;
6971
7072 return compiler . compile ( ) . then ( ( ) => {
7173 const query = new PostgresQuery ( { joinGraph, cubeEvaluator, compiler } , {
7274 measures : measures . map ( m => `cube.${ m } ` ) ,
7375 timeDimensions : [ {
7476 dimension : 'cube.created' ,
7577 granularity : queryAggTimeGranularity ,
76- dateRange : { from : '2017-01-01' , to : '2017-03-31' }
78+ dateRange,
7779 } ] ,
7880 timezone : queryTimeZone ,
7981 } ) ;
@@ -92,15 +94,43 @@ describe('Pre Aggregation by filter match tests', () => {
9294 ) ) ;
9395
9496 it ( '1 count measure, one_week_by_sunday, one_week_by_sunday' , ( ) => testPreAggregationMatch (
95- true , [ 'count' ] , 'one_week_by_sunday' , 'one_week_by_sunday'
97+ true ,
98+ [ 'count' ] ,
99+ 'one_week_by_sunday' ,
100+ 'one_week_by_sunday' ,
101+ 'UTC' ,
102+ [ '2024-02-11' , '2024-03-02' ]
96103 ) ) ;
97104
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'
105+ it ( '1 count measure, one_week_by_sunday, one_week_by_sunday (dst)' , ( ) => testPreAggregationMatch (
106+ true ,
107+ [ 'count' ] ,
108+ 'one_week_by_sunday' ,
109+ 'one_week_by_sunday' ,
110+ 'UTC' ,
111+ [ '2024-02-25' , '2024-03-30' ] , // DST Switch happens here, but still must work!
112+ ) ) ;
113+
114+ it ( '1 count measure, two_weeks_by_1st_feb_00am, two_weeks_by_1st_feb_00am (match)' , ( ) => testPreAggregationMatch (
115+ true ,
116+ [ 'count' ] ,
117+ 'two_weeks_by_1st_feb_00am' ,
118+ 'two_weeks_by_1st_feb_00am' ,
119+ 'UTC' ,
120+ [ '2024-01-18' , '2024-02-28' ]
121+ ) ) ;
122+
123+ it ( '1 count measure, two_weeks_by_1st_feb_00am, two_weeks_by_1st_feb_00am (miss)' , ( ) => testPreAggregationMatch (
124+ false ,
125+ [ 'count' ] ,
126+ 'two_weeks_by_1st_feb_00am' ,
127+ 'two_weeks_by_1st_feb_00am' ,
128+ 'UTC' ,
129+ [ '2024-01-18' , '2024-02-07' ] , // Interval not aligned
100130 ) ) ;
101131
102132 it ( '1 count measure, day, one_week_by_sunday' , ( ) => testPreAggregationMatch (
103- true , [ 'count' ] , 'day' , 'one_week_by_sunday'
133+ true , [ 'count' ] , 'day' , 'one_week_by_sunday' , 'UTC'
104134 ) ) ;
105135
106136 it ( '1 count measure, day, two_weeks_by_1st_feb_00am' , ( ) => testPreAggregationMatch (
0 commit comments