Skip to content

fix(schema-compiler): Fix non-match for exact custom granularity pre-aggregation #9517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { BaseQuery } from './BaseQuery';
import type { DimensionDefinition, SegmentDefinition } from '../compiler/CubeEvaluator';
import { CubeSymbols } from "../compiler/CubeSymbols";
import { CubeSymbols } from '../compiler/CubeSymbols';

export class BaseDimension {
public readonly expression: any;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { UserError } from '../compiler/UserError';
import type { BaseQuery } from './BaseQuery';
import { MeasureDefinition } from '../compiler/CubeEvaluator';
import { CubeSymbols } from "../compiler/CubeSymbols";
import { CubeSymbols } from '../compiler/CubeSymbols';

export class BaseMeasure {
public readonly expression: any;
Expand Down
2 changes: 1 addition & 1 deletion packages/cubejs-schema-compiler/src/adapter/BaseQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
timeSeriesFromCustomInterval
} from '@cubejs-backend/shared';

import { CubeSymbols } from "../compiler/CubeSymbols";
import { CubeSymbols } from '../compiler/CubeSymbols';
import { UserError } from '../compiler/UserError';
import { SqlParser } from '../parser/SqlParser';
import { BaseDimension } from './BaseDimension';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { BaseQuery } from './BaseQuery';
import { CubeSymbols } from "../compiler/CubeSymbols";
import { CubeSymbols } from '../compiler/CubeSymbols';

export class BaseSegment {
public readonly expression: any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,15 @@ export class BaseTimeDimension extends BaseFilter {
return this.dateRangeGranularity();
}

if (!this.dateRange) {
return this.granularityObj.minGranularity();
}

// If we have granularity and date range, we need to check
// that the interval and the granularity offset are stacked/fits with date range
if (this.granularityObj.isPredefined() ||
!this.granularityObj.isAlignedWithDateRange([this.dateFromFormatted(), this.dateToFormatted()])) {
if (this.dateRange && (this.granularityObj.isPredefined() ||
!this.granularityObj.isAlignedWithDateRange([this.dateFromFormatted(), this.dateToFormatted()]))) {
return this.query.minGranularity(this.granularityObj.minGranularity(), this.dateRangeGranularity());
}

// We return the granularity as-is, including custom ones,
// because baseQuery.granularityHierarchies correctly expands all custom granularities into hierarchies.
return this.granularityObj.granularity;
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class Granularity {
) {
this.granularity = timeDimension.granularity;
this.predefinedGranularity = isPredefinedGranularity(this.granularity);
this.queryTimezone = query.timezone;
this.queryTimezone = query.timezone || 'UTC';
this.origin = moment.tz(query.timezone).startOf('year'); // Defaults to current year start

if (this.predefinedGranularity) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import R from 'ramda';
import { FROM_PARTITION_RANGE, getEnv, TO_PARTITION_RANGE } from '@cubejs-backend/shared';

import { CubeSymbols } from "../compiler/CubeSymbols";
import { CubeSymbols } from '../compiler/CubeSymbols';
import { UserError } from '../compiler/UserError';

export class PreAggregations {
Expand Down
Loading
Loading