Skip to content

Commit

Permalink
fix: Use local dates for pre-aggregations to avoid timezone shift dis…
Browse files Browse the repository at this point in the history
…crepancies on DST timezones for timezone unaware databases like MySQL (#1941)
  • Loading branch information
paveltiunov committed Jan 30, 2021
1 parent be19976 commit f138e6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Expand Up @@ -118,6 +118,10 @@ export class BaseTimeDimension extends BaseFilter {
);
}

localDateTimeFromParam() {
return this.query.dateTimeCast(this.query.paramAllocator.allocateParam(this.dateFromFormatted()));
}

dateToFormatted() {
if (!this.dateToFormattedValue) {
this.dateToFormattedValue = this.formatToDate(this.dateRange[1]);
Expand All @@ -138,6 +142,10 @@ export class BaseTimeDimension extends BaseFilter {
);
}

localDateTimeToParam() {
return this.query.dateTimeCast(this.query.paramAllocator.allocateParam(this.dateToFormatted()));
}

dateRangeGranularity() {
if (!this.dateRange) {
return null;
Expand Down
Expand Up @@ -659,8 +659,8 @@ export class PreAggregations {
.concat(this.query.filters).concat(this.query.timeDimensions.map(dimension => dimension.dateRange && ({
filterToWhere: () => this.query.timeRangeFilter(
this.query.dimensionSql(dimension),
this.query.timeStampInClientTz(dimension.dateFromParam()),
this.query.timeStampInClientTz(dimension.dateToParam())
dimension.localDateTimeFromParam(),
dimension.localDateTimeToParam()
)
}))).filter(f => !!f);

Expand Down

0 comments on commit f138e6f

Please sign in to comment.