cube-js / cube-js/cube

Pre-aggregations with elasticsearch as datasource are not timezone aware

Open
#7,700 2 comments 0 reactions 0 assignees View on GitHub
driver:elasticsearch help wanted
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 2h
Merged PRs (30d)
181

Description

When creating pre-aggregations with different time zones and elasticsearch as a data source, the time dimension of the results is not converted to each applicable time zone because 'convertTz' is not implemented in the "ElasticSearchQuery" adapter. The convertTz function code can be as follows:

```javascript
public convertTz(field: string): string {
const tz = moment().tz(this.timezone);
// TODO respect day light saving
const [hour, minute] = tz.format('Z').split(':');
const [hourInt, minuteInt] = [parseInt(hour, 10), parseInt(minute, 10) * Math.sign(parseInt(hour, 10))];
let result = field;
if (hourInt !== 0) {
result = `TIMESTAMPADD('hour', ${hourInt}, ${result})`;
}
if (minuteInt !== 0) {
result = `TIMESTAMPADD('minute', ${minuteInt}, ${result})`;
}
return result;
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.