{"record":{"id":"f28a65162112fd93","repo":"pathwaycom/pathway","slug":"the-designated-timestamp-column-designated-timest","errorCode":null,"errorMessage":"the designated_timestamp column {designated_timestamp.name!r} must have type DateTimeNaive or DateTimeUtc, but it has type {timestamp_dtype}","messagePattern":"the designated_timestamp column (.+?) must have type DateTimeNaive or DateTimeUtc, but it has type (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/io/questdb/__init__.py","lineNumber":149,"sourceCode":"\n    And see the contents of the table.\n    \"\"\"\n    _check_entitlements(\"questdb\")\n\n    designated_timestamp_index = None\n    if designated_timestamp is not None:\n        if (\n            designated_timestamp_policy is not None\n            and designated_timestamp_policy != \"use_column\"\n        ):\n            raise ValueError(\n                f\"designated_timestamp is passed, but designated_timestamp_policy is {designated_timestamp_policy}\"\n            )\n        designated_timestamp_policy = \"use_column\"\n        designated_timestamp_index = get_column_index(table, designated_timestamp)\n        timestamp_dtype = table.schema.columns()[designated_timestamp.name].dtype\n        if timestamp_dtype not in (dt.DATE_TIME_NAIVE, dt.DATE_TIME_UTC):\n            raise ValueError(\n                f\"the designated_timestamp column {designated_timestamp.name!r} must have \"\n                f\"type DateTimeNaive or DateTimeUtc, but it has type {timestamp_dtype}\"\n            )\n    elif designated_timestamp_policy == \"use_column\":\n        raise ValueError(\n            'designated_timestamp_policy=\"use_column\" requires the '\n            \"designated_timestamp parameter to be set\"\n        )\n    elif designated_timestamp_policy is None:\n        designated_timestamp_policy = \"use_now\"\n\n    data_storage = api.DataStorage(\n        storage_type=\"questdb\",\n        path=connection_string,\n        table_name=table_name,\n        key_field_index=designated_timestamp_index,\n    )\n    data_format = api.DataFormat(","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/io/questdb/__init__.py#L131-L167","documentation":"Raised by pw.io.questdb.write when the column passed as designated_timestamp is typed anything other than dt.DATE_TIME_NAIVE or dt.DATE_TIME_UTC. QuestDB's designated timestamp is a native TIMESTAMP column, so int/float epoch columns, dates, or strings cannot be used directly and must be converted to a Pathway datetime type first.","triggerScenarios":"pw.io.questdb.write(t, conn, 't', designated_timestamp=t.ts) where the schema declares ts: int (epoch millis), ts: float, ts: str (ISO strings), or a Date type — anything but DateTimeNaive/DateTimeUtc.","commonSituations":"Ingesting epoch-millisecond columns from JSON/CSV where numbers stay ints; ISO-8601 string columns parsed later; a Date-only field used as timestamp; unit confusion between naive and UTC datetimes.","solutions":["Convert the column: t = t.with_columns(ts=pw.this.ts.dt.from_epoch_millisecond()) (or the appropriate strptime/utc conversion) so it becomes DateTimeNaive/DateTimeUtc.","Or declare the field as datetime in the schema and parse at ingest so it never lands as int/str.","If the data is genuinely date-only, do not use it as designated timestamp — omit the parameter and let QuestDB use now()."],"exampleFix":"# before\n# ts: int  (epoch millis)\npw.io.questdb.write(t, conn, \"t\", designated_timestamp=t.ts)\n\n# after\nt = t.with_columns(ts=pw.this.ts.dt.from_epoch_millisecond())\npw.io.questdb.write(t, conn, \"t\", designated_timestamp=t.ts)","handlingStrategy":"validation","validationCode":"ts_dtype = t.schema.columns()[t.ts.name].dtype\nassert ts_dtype in (dt.DATE_TIME_NAIVE, dt.DATE_TIME_UTC), f\"bad ts dtype: {ts_dtype}\"\npw.io.questdb.write(t, conn, \"t\", designated_timestamp=t.ts)","typeGuard":"def is_datetime_column(ref) -> bool:\n    from pathway import dt\n    return ref._column.dtype in (dt.DATE_TIME_NAIVE, dt.DATE_TIME_UTC)","tryCatchPattern":null,"preventionTips":["Convert epoch ints with dt.from_epoch_millisecond()/from_epoch_second() before writing.","Parse ISO strings into DateTimeNaive at ingest.","Declare timestamp fields as datetime in schemas rather than int/str."],"tags":["pathway","questdb","type-mismatch","timestamp","datetime"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}