cube-js/cube · error · Error

Unsupported timestamp precision: ${this.query.timestampPreci

Error message

Unsupported timestamp precision: ${this.query.timestampPrecision()}

What it means

formatFromDate() normalizes the 'from' bound of a time-range filter to an ISO string whose fractional-second digits match the query's timestampPrecision(). When that precision is neither 'second' (3 extra digits appended) nor 'microsecond' (handled lengths 23/26), the filter cannot format the date safely and throws. It protects against silently emitting timestamps the target DB cannot compare correctly.

Source

Thrown at packages/cubejs-schema-compiler/src/adapter/BaseFilter.ts:413

      return BaseFilter.ALWAYS_TRUE;
    }
    return this.query.afterOrOnDateFilter(column, after);
  }

  public formatFromDate(date: string): string {
    if (date) {
      if (this.query.timestampPrecision() === 3) {
        if (date.match(dateTimeLocalMsRegex)) {
          return date;
        }
      } else if (this.query.timestampPrecision() === 6) {
        if (date.length === 23 && date.match(dateTimeLocalMsRegex)) {
          return `${date}000`;
        } else if (date.length === 26 && date.match(dateTimeLocalURegex)) {
          return date;
        }
      } else {
        throw new Error(`Unsupported timestamp precision: ${this.query.timestampPrecision()}`);
      }

      if (date.match(dateRegex)) {
        return `${date}T00:00:00.${'0'.repeat(this.query.timestampPrecision())}`;
      }
    }

    if (!date) {
      return moment.tz(date, this.query.timezone).format(`YYYY-MM-DDT00:00:00.${'0'.repeat(this.query.timestampPrecision())}`);
    }

    return moment.tz(date, this.query.timezone).format(moment.HTML5_FMT.DATETIME_LOCAL_MS);
  }

  public inDbTimeZoneDateFrom(date) {
    if (date && (date === FROM_PARTITION_RANGE || date === TO_PARTITION_RANGE)) {
      return date;
    }

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Set/keep timestampPrecision to 'second' or 'microsecond' in the query/timeDimension definition
  2. Remove or fix custom overrides of timestampPrecision() in your BaseQuery subclass
  3. Align the driver's supported precisions with the data model's timeDimension granularity
  4. Check the Cube version changelog for timestamp precision handling changes

Example fix

// before (custom dialect)
timestampPrecision() { return 'millisecond'; }
// after
timestampPrecision() { return 'second'; }
Defensive patterns

Strategy: validation

Validate before calling

// Confirm precision before issuing time-filtered queries
const precision = 'second'; // must match query timestampPrecision()
if (!['second', 'microsecond'].includes(precision)) {
  throw new Error(`Unsupported timestamp precision: ${precision}`);
}

Try / catch

try {
  await cubeApi.load(query);
} catch (e) {
  if (e.message.startsWith('Unsupported timestamp precision')) {
    console.error('Fix timestampPrecision in query/dialect config:', e.message);
  }
  throw e;
}

Prevention

When it happens

Trigger: Querying a time dimension whose timestampPrecision() returns an unsupported value — e.g. a custom/overridden precision like 'millisecond' or a null precision — while a date filter's from value is formatted via inDbTimeZoneDateFrom, formattedDateRange, dateFromFormatted, or boundaryDateRangeFormatted.

Common situations: Custom dialects overriding timestampPrecision() with a nonstandard value; data model defining granularity that changed precision semantics after an upgrade; hand-built queries against a modified BaseQuery.

Related errors


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