99 utcToLocalTimeZone ,
1010 timeSeries ,
1111 localTimestampToUtc ,
12- extractDate ,
12+ parseLocalDate ,
1313} from '@cubejs-backend/shared' ;
1414import { InlineTable , TableStructure } from '@cubejs-backend/base-driver' ;
1515import { DriverFactory } from './DriverFactory' ;
@@ -411,11 +411,7 @@ export class PreAggregationPartitionRangeLoader {
411411 const { preAggregationStartEndQueries } = this . preAggregation ;
412412 const [ startDate , endDate ] = await Promise . all (
413413 preAggregationStartEndQueries . map (
414- async rangeQuery => utcToLocalTimeZone (
415- this . preAggregation . timezone ,
416- timestampFormat ,
417- PreAggregationPartitionRangeLoader . extractDate ( await this . loadRangeQuery ( rangeQuery ) ) ,
418- )
414+ async rangeQuery => PreAggregationPartitionRangeLoader . extractDate ( await this . loadRangeQuery ( rangeQuery ) , this . preAggregation . timezone , timestampFormat ) ,
419415 ) ,
420416 ) ;
421417
@@ -431,15 +427,13 @@ export class PreAggregationPartitionRangeLoader {
431427 ) ;
432428 const [ rangeStart , rangeEnd ] = await Promise . all (
433429 preAggregationStartEndQueries . map (
434- async ( rangeQuery , i ) => utcToLocalTimeZone (
430+ async ( rangeQuery , i ) => PreAggregationPartitionRangeLoader . extractDate (
431+ await this . loadRangeQuery (
432+ rangeQuery , i === 0 ? wholeSeriesRanges [ 0 ] : wholeSeriesRanges [ wholeSeriesRanges . length - 1 ] ,
433+ ) ,
435434 this . preAggregation . timezone ,
436435 timestampFormat ,
437- PreAggregationPartitionRangeLoader . extractDate (
438- await this . loadRangeQuery (
439- rangeQuery , i === 0 ? wholeSeriesRanges [ 0 ] : wholeSeriesRanges [ wholeSeriesRanges . length - 1 ] ,
440- ) ,
441- ) ,
442- )
436+ ) ,
443437 ) ,
444438 ) ;
445439 return this . orNowIfEmpty ( [ rangeStart , rangeEnd ] ) ;
@@ -536,8 +530,8 @@ export class PreAggregationPartitionRangeLoader {
536530 return localTimestampToUtc ( preAggregationDescription . timezone , preAggregationDescription . timestampFormat , timestamp ) ;
537531 }
538532
539- public static extractDate ( data : any ) : string {
540- return extractDate ( data ) ;
533+ public static extractDate ( data : any , timezone : string , timestampFormat : string = 'YYYY-MM-DDTHH:mm:ss.SSS' ) : string {
534+ return parseLocalDate ( data , timezone , timestampFormat ) ;
541535 }
542536
543537 public static FROM_PARTITION_RANGE = FROM_PARTITION_RANGE ;
0 commit comments