{"record":{"id":"c7d6b4969a79b343","repo":"cube-js/cube","slug":"unsupported-timestamp-precision-this-query-time","errorCode":null,"errorMessage":"Unsupported timestamp precision: ${this.query.timestampPrecision()}","messagePattern":"Unsupported timestamp precision: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-schema-compiler/src/adapter/BaseFilter.ts","lineNumber":413,"sourceCode":"      return BaseFilter.ALWAYS_TRUE;\n    }\n    return this.query.afterOrOnDateFilter(column, after);\n  }\n\n  public formatFromDate(date: string): string {\n    if (date) {\n      if (this.query.timestampPrecision() === 3) {\n        if (date.match(dateTimeLocalMsRegex)) {\n          return date;\n        }\n      } else if (this.query.timestampPrecision() === 6) {\n        if (date.length === 23 && date.match(dateTimeLocalMsRegex)) {\n          return `${date}000`;\n        } else if (date.length === 26 && date.match(dateTimeLocalURegex)) {\n          return date;\n        }\n      } else {\n        throw new Error(`Unsupported timestamp precision: ${this.query.timestampPrecision()}`);\n      }\n\n      if (date.match(dateRegex)) {\n        return `${date}T00:00:00.${'0'.repeat(this.query.timestampPrecision())}`;\n      }\n    }\n\n    if (!date) {\n      return moment.tz(date, this.query.timezone).format(`YYYY-MM-DDT00:00:00.${'0'.repeat(this.query.timestampPrecision())}`);\n    }\n\n    return moment.tz(date, this.query.timezone).format(moment.HTML5_FMT.DATETIME_LOCAL_MS);\n  }\n\n  public inDbTimeZoneDateFrom(date) {\n    if (date && (date === FROM_PARTITION_RANGE || date === TO_PARTITION_RANGE)) {\n      return date;\n    }","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/adapter/BaseFilter.ts#L395-L431","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before (custom dialect)\ntimestampPrecision() { return 'millisecond'; }\n// after\ntimestampPrecision() { return 'second'; }","handlingStrategy":"validation","validationCode":"// Confirm precision before issuing time-filtered queries\nconst precision = 'second'; // must match query timestampPrecision()\nif (!['second', 'microsecond'].includes(precision)) {\n  throw new Error(`Unsupported timestamp precision: ${precision}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await cubeApi.load(query);\n} catch (e) {\n  if (e.message.startsWith('Unsupported timestamp precision')) {\n    console.error('Fix timestampPrecision in query/dialect config:', e.message);\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["schema-compiler","timestamp","precision","filter","sql-generation"],"backgroundTag":"unsupported-timestamp-precision","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}