Skip to content

Commit 47c181b

Browse files
committed
fix in choosing minGranularity for granularity with origin point
1 parent 6467a90 commit 47c181b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/cubejs-schema-compiler/src/adapter/Granularity.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class Granularity {
4444
this.granularityInterval = customGranularity.interval;
4545

4646
if (customGranularity.origin) {
47-
this.origin = moment(new Date(customGranularity.origin));
47+
this.origin = moment.tz(customGranularity.origin, 'UTC');
4848
} else if (customGranularity.offset) {
4949
this.granularityOffset = customGranularity.offset;
5050
this.origin = addInterval(this.origin, parseSqlInterval(customGranularity.offset));
@@ -61,6 +61,13 @@ export class Granularity {
6161
return this.granularity;
6262
}
6363

64+
if (this.origin) {
65+
return this.query.minGranularity(
66+
this.granularityFromInterval(),
67+
this.query.granularityFor(this.origin.utc())
68+
);
69+
}
70+
6471
if (this.granularityOffset) {
6572
return this.query.minGranularity(
6673
this.granularityFromInterval(),

0 commit comments

Comments
 (0)