cube-js/cube · error · Error

Unsupported interval unit "${unit}" for the Pinot dialect

Error message

Unsupported interval unit "${unit}" for the Pinot dialect

What it means

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.

Source

Thrown at packages/cubejs-pinot-driver/src/PinotQuery.ts:134

        case 'hour':
        case 'day':
        case 'week': {
          const amount = unit === 'week' ? value * 7 : value;
          const op = amount < 0 ? '-' : '+';
          expr = `${expr} ${op} ${PINOT_EPOCH_FN[unit]}(${Math.abs(amount)})`;
          break;
        }
        case 'month':
          expr = `TIMESTAMPADD(MONTH, ${value}, ${expr})`;
          break;
        case 'quarter':
          expr = `TIMESTAMPADD(MONTH, ${value * 3}, ${expr})`;
          break;
        case 'year':
          expr = `TIMESTAMPADD(YEAR, ${value}, ${expr})`;
          break;
        default:
          throw new Error(`Unsupported interval unit "${unit}" for the Pinot dialect`);
      }
    }

    return expr;
  }

  /**
   * Floors `source` to the timestamp aligned with `interval`-sized bins relative
   * to `origin`, used for custom (non-natural-aligned) granularities.
   */
  public dateBin(interval: string, source: string, origin: string): string {
    const originAligned = this.timeStampCast(`'${origin.replace('T', ' ')}'`);
    const beginOfTime = this.timeStampCast('\'1970-01-01 00:00:00.000\'');
    const timeUnit = this.diffTimeUnitForInterval(interval).toUpperCase();
    const intervalSize = `TIMESTAMPDIFF(${timeUnit}, ${beginOfTime}, ${this.addInterval(beginOfTime, interval)})`;

    return this.timeStampCast(
      `TIMESTAMPADD(${timeUnit}, ` +

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Restrict queries/filters to supported interval units (second, minute, hour, day, week, month, quarter, year).
  2. Rewrite the expression to an equivalent supported unit (e.g., hours instead of milliseconds).
  3. Pin or upgrade the cubejs-pinot-driver version for extended unit support.

Example fix

// before
filter: { dateRange: ['2024-01-01', '2024-01-02 00:00:00.500'] } // sub-second units
// after
filter: { dateRange: ['2024-01-01', '2024-01-02'] } // supported units only
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED = new Set(['second','minute','hour','day','week','month','quarter','year']);
if (!SUPPORTED.has(unit)) throw new Error(`Interval unit ${unit} unsupported by Pinot dialect`);

Type guard

type PinotIntervalUnit = 'second'|'minute'|'hour'|'day'|'week'|'month'|'quarter'|'year';
function isPinotUnit(u: string): u is PinotIntervalUnit {
  return ['second','minute','hour','day','week','month','quarter','year'].includes(u);
}

Try / catch

try {
  const sql = compileForPinot(query);
} catch (e) {
  if (e.message.includes('Unsupported interval unit')) {
    console.error('Rewrite the filter/window using supported units');
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: Using date ranges or rolling window calculations with time granularities Pinot's dialect mapping does not support; schema changes introducing new interval units upstream.

Related errors


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/1921eab5f129a14e. Report an issue: GitHub.