Skip to content

Commit

Permalink
fix in choosing minGranularity for granularity with origin point
Browse files Browse the repository at this point in the history
  • Loading branch information
KSDaemon committed Sep 12, 2024
1 parent 6467a90 commit 47c181b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/cubejs-schema-compiler/src/adapter/Granularity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class Granularity {
this.granularityInterval = customGranularity.interval;

if (customGranularity.origin) {
this.origin = moment(new Date(customGranularity.origin));
this.origin = moment.tz(customGranularity.origin, 'UTC');
} else if (customGranularity.offset) {
this.granularityOffset = customGranularity.offset;
this.origin = addInterval(this.origin, parseSqlInterval(customGranularity.offset));
Expand All @@ -61,6 +61,13 @@ export class Granularity {
return this.granularity;
}

if (this.origin) {
return this.query.minGranularity(
this.granularityFromInterval(),
this.query.granularityFor(this.origin.utc())
);
}

if (this.granularityOffset) {
return this.query.minGranularity(
this.granularityFromInterval(),
Expand Down

0 comments on commit 47c181b

Please sign in to comment.