{"record":{"id":"1921eab5f129a14e","repo":"cube-js/cube","slug":"unsupported-interval-unit-unit-for-the-pinot","errorCode":null,"errorMessage":"Unsupported interval unit \"${unit}\" for the Pinot dialect","messagePattern":"Unsupported interval unit \"(.+?)\" for the Pinot dialect","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-pinot-driver/src/PinotQuery.ts","lineNumber":134,"sourceCode":"        case 'hour':\n        case 'day':\n        case 'week': {\n          const amount = unit === 'week' ? value * 7 : value;\n          const op = amount < 0 ? '-' : '+';\n          expr = `${expr} ${op} ${PINOT_EPOCH_FN[unit]}(${Math.abs(amount)})`;\n          break;\n        }\n        case 'month':\n          expr = `TIMESTAMPADD(MONTH, ${value}, ${expr})`;\n          break;\n        case 'quarter':\n          expr = `TIMESTAMPADD(MONTH, ${value * 3}, ${expr})`;\n          break;\n        case 'year':\n          expr = `TIMESTAMPADD(YEAR, ${value}, ${expr})`;\n          break;\n        default:\n          throw new Error(`Unsupported interval unit \"${unit}\" for the Pinot dialect`);\n      }\n    }\n\n    return expr;\n  }\n\n  /**\n   * Floors `source` to the timestamp aligned with `interval`-sized bins relative\n   * to `origin`, used for custom (non-natural-aligned) granularities.\n   */\n  public dateBin(interval: string, source: string, origin: string): string {\n    const originAligned = this.timeStampCast(`'${origin.replace('T', ' ')}'`);\n    const beginOfTime = this.timeStampCast('\\'1970-01-01 00:00:00.000\\'');\n    const timeUnit = this.diffTimeUnitForInterval(interval).toUpperCase();\n    const intervalSize = `TIMESTAMPDIFF(${timeUnit}, ${beginOfTime}, ${this.addInterval(beginOfTime, interval)})`;\n\n    return this.timeStampCast(\n      `TIMESTAMPADD(${timeUnit}, ` +","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-pinot-driver/src/PinotQuery.ts#L116-L152","documentation":"PinotQuery.applyInterval translates date arithmetic into Pinot's TIMESTAMPADD function. It supports only a fixed set of units (e.g., second/minute/hour/day/week/month/quarter/year); any other unit passed from addInterval/subtractInterval hits the default case and throws.","triggerScenarios":"A compiled query uses a date filter or rolling window with an interval unit not mapped in applyInterval (e.g., a granular unit like milliseconds or an exotic unit) while generating SQL for the Pinot dialect.","commonSituations":"Using date ranges or rolling window calculations with time granularities Pinot's dialect mapping does not support; schema changes introducing new interval units upstream.","solutions":["Restrict queries/filters to supported interval units (second, minute, hour, day, week, month, quarter, year).","Rewrite the expression to an equivalent supported unit (e.g., hours instead of milliseconds).","Pin or upgrade the cubejs-pinot-driver version for extended unit support."],"exampleFix":"// before\nfilter: { dateRange: ['2024-01-01', '2024-01-02 00:00:00.500'] } // sub-second units\n// after\nfilter: { dateRange: ['2024-01-01', '2024-01-02'] } // supported units only","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set(['second','minute','hour','day','week','month','quarter','year']);\nif (!SUPPORTED.has(unit)) throw new Error(`Interval unit ${unit} unsupported by Pinot dialect`);","typeGuard":"type PinotIntervalUnit = 'second'|'minute'|'hour'|'day'|'week'|'month'|'quarter'|'year';\nfunction isPinotUnit(u: string): u is PinotIntervalUnit {\n  return ['second','minute','hour','day','week','month','quarter','year'].includes(u);\n}","tryCatchPattern":"try {\n  const sql = compileForPinot(query);\n} catch (e) {\n  if (e.message.includes('Unsupported interval unit')) {\n    console.error('Rewrite the filter/window using supported units');\n  }\n  throw e;\n}","preventionTips":["Restrict date filters/rolling windows to supported units.","Convert sub-second or exotic units to seconds/hours upstream.","Add a dialect support matrix to your data-model review checklist.","Test date-range queries against Pinot in CI."],"tags":["pinot","sql-generation","interval","dialect"],"backgroundTag":"unsupported-sql-feature","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}