{"record":{"id":"c2e51440373af177","repo":"cube-js/cube","slug":"time-series-queries-without-daterange-aren-t-suppo-c2e514","errorCode":null,"errorMessage":"Time series queries without dateRange aren't supported","messagePattern":"Time series queries without dateRange aren't supported","errorType":"validation","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cubejs-schema-compiler/src/adapter/BaseTimeDimension.ts","lineNumber":268,"sourceCode":"            // that the interval and the granularity offset are stacked/fits with date range\n            if (this.dateRange && (this.granularityObj.isPredefined() ||\n              !this.granularityObj.isAlignedWithDateRange([this.dateFromFormatted(), this.dateToFormatted()]))) {\n              return this.query.minGranularity(this.granularityObj.minGranularity(), this.dateRangeGranularity());\n            }\n\n            // We return the granularity as-is, including custom ones,\n            // because baseQuery.granularityHierarchies correctly expands all custom granularities into hierarchies.\n            return this.granularityObj.granularity;\n          }\n        );\n    }\n\n    return this.rollupGranularityValue;\n  }\n\n  public timeSeries() {\n    if (!this.dateRange) {\n      throw new UserError('Time series queries without dateRange aren\\'t supported');\n    }\n\n    if (!this.granularityObj) {\n      return [[this.dateFromFormatted(), this.dateToFormatted()]];\n    }\n\n    return this.granularityObj.timeSeriesForInterval([this.dateFromFormatted(), this.dateToFormatted()], { timestampPrecision: this.query.timestampPrecision() });\n  }\n\n  public resolvedGranularity() {\n    return this.granularityObj ? this.granularityObj.resolvedGranularity() : null;\n  }\n\n  public resolvedGranularityAsIs() {\n    return this.granularityObj ? this.granularityObj.granularity : null;\n  }\n\n  public wildcardRange() {","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/adapter/BaseTimeDimension.ts#L250-L286","documentation":"BaseTimeDimension.timeSeries() generates the array of date intervals for a time-series query, which requires an explicit dateRange to compute start/end. Called by values() and seriesSql(), it throws this UserError when the query has no dateRange — without it the series would be unbounded.","triggerScenarios":"Issuing a time-series query (e.g. granularity with series generation, used by charting/rolling window flows) where timeDimensions entry lacks a dateRange — e.g. { dimension: 'Orders.createdAt', granularity: 'day' } with no dateRange, or dateRange: null.","commonSituations":"BI client requesting a series without a date filter; passing only dateRangeMapped or forgetting dateRange when constructing queries programmatically; using seriesSql-dependent features on unbounded queries.","solutions":["Add a dateRange to the timeDimension of the query, e.g. dateRange: ['2024-01-01', '2024-03-31']","If an open-ended query is intended, compute a concrete dateRange client-side before sending","For rolling windows, use dateRange expressions like 'last month' that resolve to a bounded range"],"exampleFix":"// before\ntimeDimensions: [{ dimension: 'Orders.createdAt', granularity: 'day' }]\n// after\ntimeDimensions: [{ dimension: 'Orders.createdAt', granularity: 'day', dateRange: ['2024-01-01', '2024-01-31'] }]","handlingStrategy":"validation","validationCode":"function validateTimeDimensions(query) {\n  for (const td of query.timeDimensions || [])\n    if (td.granularity && !td.dateRange) throw new Error('Time-series queries require a dateRange');\n}","typeGuard":"const hasBoundedDateRange = (td) => Array.isArray(td?.dateRange) && td.dateRange.length === 2 && td.dateRange.every(Boolean);","tryCatchPattern":"try { const res = await cubeApi.load(q); } catch (e) { if (/Time series queries without dateRange/.test(e.message)) { q.timeDimensions.forEach(td => td.dateRange ||= defaultRange()); return cubeApi.load(q); } throw e; }","preventionTips":["Always attach a dateRange to timeDimensions that specify a granularity","Use relative ranges ('last week') so the range stays bounded","Validate queries client-side before sending them to the API"],"tags":["time-dimension","time-series","validation"],"backgroundTag":"missing-daterange","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}