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
- Set/keep timestampPrecision to 'second' or 'microsecond' in the query/timeDimension definition
- Remove or fix custom overrides of timestampPrecision() in your BaseQuery subclass
- Align the driver's supported precisions with the data model's timeDimension granularity
- 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
- Only override timestampPrecision() with 'second' or 'microsecond'
- Keep timeDimension granularity aligned with driver-supported precisions
- Add unit tests for custom dialects covering date filter formatting
- Review Cube changelogs when upgrading for precision semantics changes
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
- Expected only 2 parameters for timestamp filter but got: ${t
- Expected one parameter but nothing found
- Hierarchical time shift is not supported but was provided fo
- Unsupported interval unit "${unit}" for the Pinot dialect
- Date range expected to be in ${DEFAULT_TS_FORMAT} format but
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/c7d6b4969a79b343.
Report an issue: GitHub.