cube-js/cube · error · UserError

Only fixed rolling windows are supported by Cube Store but g

Error message

Only fixed rolling windows are supported by Cube Store but got '${type}' rolling window

What it means

Cube Store pre-aggregations support only fixed rolling windows. rollingWindowDefinition() inspects the measure's rollingWindow.type and throws this UserError if it is 'unbounded', 'trailing', 'leading', or any other non-fixed value, because Cube Store cannot compute those window semantics in a pre-aggregation.

Source

Thrown at packages/cubejs-schema-compiler/src/adapter/BaseMeasure.ts:269

    if (this.expression) { // TODO
      return false;
    }
    const definition = this.measureDefinition();
    if (definition.multiStage) {
      return false;
    }
    return definition.type === 'sum' || definition.type === 'count' || definition.type === 'countDistinctApprox' ||
      definition.type === 'min' || definition.type === 'max';
  }

  public static isCumulative(definition): boolean {
    return !!definition.rollingWindow;
  }

  public rollingWindowDefinition() {
    const { type } = this.measureDefinition().rollingWindow;
    if (type && type !== 'fixed') {
      throw new UserError(`Only fixed rolling windows are supported by Cube Store but got '${type}' rolling window`);
    }
    return this.measureDefinition().rollingWindow;
  }

  public dateJoinCondition() {
    const definition = this.measureDefinition();
    const { rollingWindow } = definition;
    if (rollingWindow.type === 'to_date') {
      return this.query.rollingWindowToDateJoinCondition(rollingWindow.granularity);
    }
    // TODO deprecated
    if (rollingWindow.type === 'year_to_date' || rollingWindow.type === 'quarter_to_date' || rollingWindow.type === 'month_to_date') {
      return this.query.rollingWindowToDateJoinCondition(rollingWindow.type.replace('_to_date', ''));
    }
    if (rollingWindow) {
      return this.query.rollingWindowDateJoinCondition(
        rollingWindow.trailing, rollingWindow.leading, rollingWindow.offset
      );

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Change the rolling window type to 'fixed' (with a dateRange) if Cube Store pre-aggregation is required
  2. Use a non-Cube-Store pre-aggregation target (e.g. a database that supports the window) for trailing/leading windows
  3. Rephrase the analysis as a fixed-range query or compute trailing windows in the query layer without the pre-aggregation
  4. Remove rollingWindow from the measure and use a calculated timeDimension range instead

Example fix

// before
rollingWindow: { type: 'trailing', trailing: '7 day' }
// after
rollingWindow: { type: 'fixed', dateRange: ['2024-01-01', '2024-01-07'] }
Defensive patterns

Strategy: validation

Validate before calling

function validateRollingWindow(measureDef) {
  const rw = measureDef.rollingWindow;
  if (rw && rw.type && rw.type !== 'fixed') {
    throw new Error(`Rolling window type '${rw.type}' not supported by Cube Store; use 'fixed'`);
  }
}

Type guard

function hasFixedRollingWindow(def) {
  return !def.rollingWindow || !def.rollingWindow.type || def.rollingWindow.type === 'fixed';
}

Try / catch

try {
  await cubeApi.load(query);
} catch (e) {
  if (e.message.startsWith('Only fixed rolling windows are supported')) {
    console.error('Use fixed windows or a non-Cube-Store pre-aggregation:', e.message);
  }
  throw e;
}

Prevention

When it happens

Trigger: Defining a measure with rollingWindow: { type: 'unbounded' | 'trailing' | 'leading', ... } and querying it in a way that plans into a Cube Store pre-aggregation (rollingWindowDefinition is called during pre-aggregation planning for rolling-window measures).

Common situations: Migrating rolling-window queries from Postgres-backed pre-aggregations to Cube Store; defining trailing/leading windows like 'trailing 7 days' on a Cube Store-targeted pre-aggregation; copying examples with unbounded windows into Cube Store configs.

Related errors


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/e863dc548fdb8d27. Report an issue: GitHub.