Skip to content

Commit bfad841

Browse files
committed
another round in loadBuildRange()
1 parent a73ccff commit bfad841

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

packages/cubejs-query-orchestrator/src/orchestrator/PreAggregationPartitionRangeLoader.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ export class PreAggregationPartitionRangeLoader {
136136
return queryValues?.map(
137137
param => {
138138
if (param === BUILD_RANGE_START_LOCAL) {
139-
return utcToLocalTimeZone(this.preAggregation.timezone, this.preAggregation.timestampFormat, buildRangeStart);
139+
return buildRangeStart;
140140
} else if (param === BUILD_RANGE_END_LOCAL) {
141-
return utcToLocalTimeZone(this.preAggregation.timezone, this.preAggregation.timestampFormat, buildRangeEnd);
141+
return buildRangeEnd;
142142
} else {
143143
return param;
144144
}
@@ -367,11 +367,8 @@ export class PreAggregationPartitionRangeLoader {
367367

368368
private async partitionRanges(ignoreMatchedDateRange?: boolean): Promise<PartitionRanges> {
369369
const buildRange = await this.loadBuildRange();
370-
if (!buildRange[0] || !buildRange[1]) {
371-
return { buildRange, partitionRanges: [] };
372-
}
373370

374-
// buildRange is localized in loadBuildRange()
371+
// buildRange was localized in loadBuildRange()
375372
// preAggregation.matchedTimeDimensionDateRange is also localized
376373
// in BaseFilter->formatToDate()/formatFromDate()
377374
let dateRange = PreAggregationPartitionRangeLoader.intersectDateRanges(
@@ -385,6 +382,12 @@ export class PreAggregationPartitionRangeLoader {
385382
dateRange = [buildRange[1], buildRange[1]];
386383
}
387384

385+
// Partitions are built and named in UTC
386+
dateRange = [
387+
localTimestampToUtc(this.preAggregation.timezone, 'YYYY-MM-DDTHH:mm:ss.SSS', dateRange[0]),
388+
localTimestampToUtc(this.preAggregation.timezone, 'YYYY-MM-DDTHH:mm:ss.SSS', dateRange[1]),
389+
];
390+
388391
const partitionRanges = this.compilerCacheFn(
389392
['timeSeries', this.preAggregation.partitionGranularity, JSON.stringify(dateRange), `${this.preAggregation.timestampPrecision}`],
390393
() => PreAggregationPartitionRangeLoader.timeSeries(
@@ -407,7 +410,7 @@ export class PreAggregationPartitionRangeLoader {
407410
const { preAggregationStartEndQueries } = this.preAggregation;
408411
const [startDate, endDate] = await Promise.all(
409412
preAggregationStartEndQueries.map(
410-
async rangeQuery => localTimestampToUtc(
413+
async rangeQuery => utcToLocalTimeZone(
411414
this.preAggregation.timezone,
412415
'YYYY-MM-DDTHH:mm:ss.SSS',
413416
PreAggregationPartitionRangeLoader.extractDate(await this.loadRangeQuery(rangeQuery)),
@@ -427,7 +430,7 @@ export class PreAggregationPartitionRangeLoader {
427430
);
428431
const [rangeStart, rangeEnd] = await Promise.all(
429432
preAggregationStartEndQueries.map(
430-
async (rangeQuery, i) => localTimestampToUtc(
433+
async (rangeQuery, i) => utcToLocalTimeZone(
431434
this.preAggregation.timezone,
432435
'YYYY-MM-DDTHH:mm:ss.SSS',
433436
PreAggregationPartitionRangeLoader.extractDate(

0 commit comments

Comments
 (0)