Skip to content

Commit 39efd0a

Browse files
committed
actual fix
1 parent d28333a commit 39efd0a

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,17 +249,15 @@ export class BaseTimeDimension extends BaseFilter {
249249
return this.dateRangeGranularity();
250250
}
251251

252-
if (!this.dateRange) {
253-
return this.granularityObj.minGranularity();
254-
}
255-
256252
// If we have granularity and date range, we need to check
257253
// that the interval and the granularity offset are stacked/fits with date range
258-
if (this.granularityObj.isPredefined() ||
259-
!this.granularityObj.isAlignedWithDateRange([this.dateFromFormatted(), this.dateToFormatted()])) {
254+
if (this.dateRange && (this.granularityObj.isPredefined() ||
255+
!this.granularityObj.isAlignedWithDateRange([this.dateFromFormatted(), this.dateToFormatted()]))) {
260256
return this.query.minGranularity(this.granularityObj.minGranularity(), this.dateRangeGranularity());
261257
}
262258

259+
// We return the granularity as-is, including custom ones,
260+
// because baseQuery.granularityHierarchies correctly expands all custom granularities into hierarchies.
263261
return this.granularityObj.granularity;
264262
}
265263
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class Granularity {
3131
) {
3232
this.granularity = timeDimension.granularity;
3333
this.predefinedGranularity = isPredefinedGranularity(this.granularity);
34-
this.queryTimezone = query.timezone;
34+
this.queryTimezone = query.timezone || 'UTC';
3535
this.origin = moment.tz(query.timezone).startOf('year'); // Defaults to current year start
3636

3737
if (this.predefinedGranularity) {

0 commit comments

Comments
 (0)