{"record":{"id":"d08dea9f9ce3365b","repo":"cube-js/cube","slug":"mixed-offset-rolling-window-querying-is-not-suppor","errorCode":null,"errorMessage":"Mixed offset rolling window querying is not supported","messagePattern":"Mixed offset rolling window querying is not supported","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-schema-compiler/src/adapter/CubeStoreQuery.ts","lineNumber":295,"sourceCode":"      trailing = a.trailing;\n    } else {\n      trailing = this.parseSecondDuration(a.trailing) > this.parseSecondDuration(b.trailing) ? a.trailing : b.trailing;\n    }\n\n    let leading;\n    if (a.leading === 'unbounded' || b.leading === 'unbounded') {\n      leading = 'unbounded';\n    } else if (!a.leading) {\n      leading = b.leading;\n    } else if (!b.leading) {\n      leading = a.leading;\n    } else {\n      leading = this.parseSecondDuration(a.leading) > this.parseSecondDuration(b.leading) ? a.leading : b.leading;\n    }\n\n    if ((a.offset || 'end') !== (b.offset || 'end')) {\n      // TODO introduce virtual 'both' offset and return it if max receives 'start' and 'end'\n      throw new Error('Mixed offset rolling window querying is not supported');\n    }\n\n    return {\n      trailing,\n      leading,\n      offset: a.offset\n    };\n  }\n\n  public overTimeSeriesForSelectRollup(cumulativeMeasures, otherMeasures, timeDimension, preAggregationForQuery) {\n    const rollupMeasures = this.preAggregations.rollupMeasures(preAggregationForQuery);\n    const renderedReference = rollupMeasures.map(measure => {\n      const m = this.newMeasure(measure);\n      const renderSql = () => {\n        if (timeDimension && m.isCumulative()) {\n          const measureSql = m.cumulativeMeasureSql();\n          const rollingWindow = m.rollingWindowDefinition();\n          const preceding = rollingWindow.trailing ? `${this.toInterval(rollingWindow.trailing)} PRECEDING` : '';","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/adapter/CubeStoreQuery.ts#L277-L313","documentation":"When computing the maximum rolling window of two windows, if one window has offset 'start' (leading from start) and the other 'end' (or unset), no single combined window can represent both, so maxRollingWindow throws. The TODO notes a virtual 'both' offset would be needed.","triggerScenarios":"A query (or merged query with multiple rolling windows on the same cube) mixes windows like `{ trailing: '2 day', offset: 'start' }` and `{ trailing: '2 day', offset: 'end' }`.","commonSituations":"Comparing current-period-to-date (offset: 'start') with trailing complete windows (offset: 'end') in the same query; orchestrator merging two queried rolling windows into one pre-aggregation window.","solutions":["Make all rolling windows in the query use the same offset (all 'start' or all 'end').","Split into two separate queries, one per offset type.","Remove the explicit offset from one window so both default to 'end'."],"exampleFix":"// before\nrollingWindow: { trailing: '2 day', offset: 'start' } // in one measure\nrollingWindow: { trailing: '7 day' } // in another -> defaults to 'end'\n// after\nrollingWindow: { trailing: '2 day', offset: 'end' }\nrollingWindow: { trailing: '7 day', offset: 'end' }","handlingStrategy":"validation","validationCode":"const offsets = measures.map(m => m.rollingWindow?.offset || 'end');\nif (new Set(offsets).size > 1) throw new Error('All rolling windows must share the same offset');","typeGuard":null,"tryCatchPattern":"try { await cube.load(q) } catch (e) { if (/Mixed offset rolling window/.test(e.message)) { /* split query per offset */ } else throw e; }","preventionTips":["Standardize offset ('start' vs 'end') across rolling windows in a project","Split comparisons of MTD vs trailing windows into separate queries","Code-review rollingWindow configs for offset consistency"],"tags":["cubestore","rolling-window","offset","time-dimension"],"backgroundTag":"unsupported-rolling-window-offset","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}