{"record":{"id":"676a85e5e5ea98fc","repo":"cube-js/cube","slug":"complex-intervals-like-interval-are-not-suppo","errorCode":null,"errorMessage":"Complex intervals like \"${interval}\" are not supported. Please use Year to Month or Day to second intervals","messagePattern":"Complex intervals like \"(.+?)\" are not supported\\. Please use Year to Month or Day to second intervals","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-schema-compiler/src/adapter/RedshiftQuery.ts","lineNumber":55,"sourceCode":"    let result = date;\n\n    for (const [datePart, intervalValue] of Object.entries(intervalParsed)) {\n      result = `DATEADD(${datePart}, ${intervalValue}, ${result})`;\n    }\n\n    return result;\n  }\n\n  /**\n   * Redshift doesn't support Interval values with month or year parts (as Postgres does)\n   * so we need to make date math on our own.\n   */\n  public override dateBin(interval: string, source: string, origin: string): string {\n    const intervalParsed = parseSqlInterval(interval);\n\n    if ((intervalParsed.year || intervalParsed.month || intervalParsed.quarter) &&\n        (intervalParsed.week || intervalParsed.day || intervalParsed.hour || intervalParsed.minute || intervalParsed.second)) {\n      throw new Error(`Complex intervals like \"${interval}\" are not supported. Please use Year to Month or Day to second intervals`);\n    }\n\n    if (intervalParsed.year || intervalParsed.month || intervalParsed.quarter) {\n      let totalMonths = 0;\n\n      if (intervalParsed.year) {\n        totalMonths += intervalParsed.year * 12;\n      }\n\n      if (intervalParsed.quarter) {\n        totalMonths += intervalParsed.quarter * 3;\n      }\n\n      if (intervalParsed.month) {\n        totalMonths += intervalParsed.month;\n      }\n\n      return `DATEADD(","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/adapter/RedshiftQuery.ts#L37-L73","documentation":"Redshift cannot apply date_bin with intervals that mix month-family units (year/month/quarter) and time-family units (week/day/hour/minute/second), since such intervals have no fixed length. dateBin throws this error when parseSqlInterval yields parts from both families.","triggerScenarios":"Calling dateBin with a compound interval like '1 month 2 days', '1 year 3 hours', or '2 quarter 5 minute' on a RedshiftQuery instance (directly or via dateBin-based granularity).","commonSituations":"Reusing a Postgres-style granularity interval in a Redshift pre-aggregation; copy-pasting interval strings like '1 year 6 months' from other dialects; generated granularities that combine units.","solutions":["Use an interval from a single family: either Y/M/Q only (e.g. '3 months') or W/D/H/MIN/S only (e.g. '2 days 3 hours' is still mixed-unit day-to-second, so prefer one unit like '1 day' if it still throws — day-to-second combos without month parts are allowed per the message)","Convert month-family intervals to an approximate day count only if your data semantics allow it","Define separate granularities/pre-aggregations per unit instead of one compound interval"],"exampleFix":"// before\nconst interval = '1 year 6 months';\nquery.dateBin(interval, src, origin);\n// after\nconst interval = '18 months'; // single month-family interval","handlingStrategy":"validation","validationCode":"const p = parseSqlInterval(interval);\nconst hasMonthFamily = !!(p.year || p.month || p.quarter);\nconst hasTimeFamily = !!(p.week || p.day || p.hour || p.minute || p.second);\nif (hasMonthFamily && hasTimeFamily) throw new Error('Redshift: split month-family and day-to-second intervals');","typeGuard":null,"tryCatchPattern":"try { return query.dateBin(interval, src, origin); } catch (e) { if (e.message.includes('Complex intervals')) { /* substitute single-family interval */ } throw e; }","preventionTips":["Restrict Redshift granularity intervals to one family","Document allowed intervals per driver","Test dateBin compilation per dialect in CI"],"tags":["redshift","interval","datebin"],"backgroundTag":"unsupported-interval-precision","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}