{"record":{"id":"b1b552804efc3702","repo":"cube-js/cube","slug":"hierarchical-time-shift-is-not-supported-but-was-p","errorCode":null,"errorMessage":"Hierarchical time shift is not supported but was provided for '${memPath}'. Parent time shift is '${symbol.shiftInterval}' and current is '${this.safeEvaluateSymbolContext().timeShifts?.[memPath]}'","messagePattern":"Hierarchical time shift is not supported but was provided for '(.+?)'\\. Parent time shift is '(.+?)' and current is '(.+?)'","errorType":"validation","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cubejs-schema-compiler/src/adapter/BaseQuery.js","lineNumber":3541,"sourceCode":"          const td = this.newTimeDimension({\n            dimension: this.cubeEvaluator.pathFromArray([cubeName, name]),\n            granularity: subPropertyName\n          });\n          // for time dimension with granularity convertedToTz() is called internally in dimensionSql() flow,\n          // so we need to ignore convertTz later even if context convertTzForRawTimeDimension is set to true\n          return this.evaluateSymbolSqlWithContext(\n            () => td.dimensionSql(),\n            { ignoreConvertTzForTimeDimension: true },\n          );\n        } else {\n          let res = this.autoPrefixAndEvaluateSql(cubeName, symbol.sql, isMemberExpr);\n          const memPath = this.cubeEvaluator.pathFromArray([cubeName, name]);\n\n          // Skip view's member evaluation as there will be underlying cube's same member evaluation\n          if (symbol.type === 'time' && !this.cubeEvaluator.cubeFromPath(memPath).isView) {\n            if (this.safeEvaluateSymbolContext().timeShifts?.[memPath]) {\n              if (symbol.shiftInterval) {\n                throw new UserError(`Hierarchical time shift is not supported but was provided for '${memPath}'. Parent time shift is '${symbol.shiftInterval}' and current is '${this.safeEvaluateSymbolContext().timeShifts?.[memPath]}'`);\n              }\n              res = `(${this.addTimestampInterval(res, this.safeEvaluateSymbolContext().timeShifts?.[memPath])})`;\n            } else if (this.safeEvaluateSymbolContext().commonTimeShift) {\n              if (symbol.shiftInterval) {\n                throw new UserError(`Hierarchical time shift is not supported but was provided for '${memPath}'. Parent time shift is '${symbol.shiftInterval}' and current is '${this.safeEvaluateSymbolContext().commonTimeShift}'`);\n              }\n              res = `(${this.addTimestampInterval(res, this.safeEvaluateSymbolContext().commonTimeShift)})`;\n            }\n          }\n\n          if (this.safeEvaluateSymbolContext().convertTzForRawTimeDimension &&\n            !this.safeEvaluateSymbolContext().ignoreConvertTzForTimeDimension &&\n            !memberExpressionType &&\n            symbol.type === 'time' &&\n            this.cubeEvaluator.byPathAnyType(memberPathArray).ownedByCube\n          ) {\n            res = this.convertTz(res);\n          }","sourceCodeStart":3523,"sourceCodeEnd":3559,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/adapter/BaseQuery.js#L3523-L3559","documentation":"Cube propagates time shifts hierarchically when evaluating time symbols: a parent's shift is applied to child members. Applying another shift inside an already-shifted member is ambiguous/unsupported, so Cube throws this UserError when both a hierarchical shift (timeShifts[memPath] or commonTimeShift) and the symbol's own shiftInterval are present.","triggerScenarios":"A time dimension (non-view) is evaluated with a timeShift in the evaluation context (or a commonTimeShift), and the same member's symbol also defines its own shiftInterval — e.g. shifting a shifted dimension, or a query-level timeShift applied to a dimension that already has a shiftInterval in its definition.","commonSituations":"Applying query-level timeShifts (dateRange shift API) on top of schema-defined shifted dimensions; nested shifted views; rolling window definitions combined with per-query time shift parameters.","solutions":["Remove the shiftInterval from the member definition OR remove the query-level/commonTimeShift for that dimension — apply only one shift.","Apply the combined shift manually: compute the net interval and pass a single timeShift.","If the member lives in a view, ensure the shift is applied at one level only (view OR cube), not both.","Catch UserError and surface guidance that hierarchical (stacked) time shifts are unsupported."],"exampleFix":"// before (schema shift + query shift collide)\nshiftInterval: '-1 month'  // in dimension definition\n// and query: timeShifts: { 'Orders.createdAt': '-1 month' }\n// after (single shift)\n// remove schema shiftInterval, keep only:\nquery.timeShifts = { 'Orders.createdAt': '-2 month' } // combine intervals manually","handlingStrategy":"validation","validationCode":"// Ensure a member is shifted at most once (schema OR query), never both\nfunction assertSingleShift(dimensionDef, queryTimeShifts, memberPath) {\n  const schemaShift = Boolean(dimensionDef && dimensionDef.shiftInterval);\n  const queryShift = Boolean(queryTimeShifts && queryTimeShifts[memberPath]);\n  if (schemaShift && queryShift) {\n    throw new Error(`Member ${memberPath} is shifted both in schema and query; remove one`);\n  }\n}","typeGuard":"const hasNoStackedShift = (symbol, ctx, memPath) => !((ctx.timeShifts?.[memPath] || ctx.commonTimeShift) && symbol.shiftInterval);","tryCatchPattern":"try {\n  return await cubeApi.load(query);\n} catch (e) {\n  if (/Hierarchical time shift is not supported/.test(e.message)) {\n    console.error('Apply the time shift at one level only (schema or query)');\n  }\n  throw e;\n}","preventionTips":["Apply time shifts in exactly one place: schema definition or query parameter","Combine multiple shifts into a single net interval manually before querying","Document view-level shifts so teams don't add a second shift at query time"],"tags":["time-shift","time-dimensions","unsupported"],"backgroundTag":"hierarchical-time-shift-unsupported","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}