{"record":{"id":"d4893d99fcad2a73","repo":"pathwaycom/pathway","slug":"unsupported-type-input-type-use-pw-date-time-ut","errorCode":null,"errorMessage":"Unsupported type {input_type}, use pw.DATE_TIME_UTC or pw.DATE_TIME_NAIVE","messagePattern":"Unsupported type (.+?), use pw\\.DATE_TIME_UTC or pw\\.DATE_TIME_NAIVE","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/dtype.py","lineNumber":741,"sourceCode":"    elif input_type == np.ndarray:\n        return ANY_ARRAY\n    elif typing.get_origin(input_type) == np.ndarray:\n        dims, wrapped = typing.get_args(input_type)\n        dims_args = typing.get_args(dims)\n        if dims == typing.Any or (dims_args and dims_args[-1] is ...):\n            # tuple[X, ...] shapes (used by NDArray on numpy >= 2.1) leave the\n            # number of dimensions unspecified, same as the older Any shape\n            return Array(n_dim=None, wrapped=wrap(wrapped))\n        return Array(n_dim=len(dims_args), wrapped=wrap(wrapped))\n    elif input_type == api.PyObjectWrapper:\n        return ANY_PY_OBJECT_WRAPPER\n    elif typing.get_origin(input_type) == api.PyObjectWrapper:\n        (inner,) = typing.get_args(input_type)\n        return PyObjectWrapper(inner)\n    elif isinstance(input_type, type) and issubclass(input_type, Enum):\n        return ANY\n    elif input_type == datetime.datetime:\n        raise TypeError(\n            f\"Unsupported type {input_type}, use pw.DATE_TIME_UTC or pw.DATE_TIME_NAIVE\"\n        )\n    elif input_type == datetime.timedelta:\n        raise TypeError(f\"Unsupported type {input_type}, use pw.DURATION\")\n    elif typing.get_origin(input_type) == asyncio.Future:\n        args = get_args(input_type)\n        (arg,) = args\n        return Future(wrap(arg))\n    else:\n        dtype = {\n            int: INT,\n            bool: BOOL,\n            str: STR,\n            float: FLOAT,\n            datetime_types.Duration: DURATION,\n            datetime_types.DateTimeNaive: DATE_TIME_NAIVE,\n            datetime_types.DateTimeUtc: DATE_TIME_UTC,\n            np.int32: INT,","sourceCodeStart":723,"sourceCodeEnd":759,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/dtype.py#L723-L759","documentation":"Pathway's type system does not accept the raw Python typing.Union/datetime.datetime class as a column dtype. datetimes must be declared as timezone-aware (pw.DateTimeUtc, written DATE_TIME_UTC) or naive (DATE_TIME_NAIVE), because Pathway tracks timezone semantics explicitly in its engine. dtype.py raises this TypeError during dtype translation to force that choice.","triggerScenarios":"Defining a schema with dt.datetime or datetime.datetime as a field type (e.g. class S(pw.Schema): ts: datetime.datetime); passing datetime.datetime to pw.schema_from_types or any dtype inference API that calls the dtype wrapper.","commonSituations":"Writing schemas by habit from pandas/SQLAlchemy models where datetime is one type; upgrading code that used python's datetime in UDF annotations; annotating connector schema fields without reading Pathway's datetime rules.","solutions":["Use pw.DateTimeUtc (pw.DATE_TIME_UTC) if values carry timezone info (e.g. pandas tz-aware or ISO strings with offset)","Use pw.DateTimeNaive (pw.DATE_TIME_NAIVE) if values have no timezone component","If you truly need arbitrary python objects, use pw.PyObjectWrapper (pw.Any) instead of datetime.datetime"],"exampleFix":"// before\nimport datetime\nclass Events(pw.Schema):\n    ts: datetime.datetime\n// after\nclass Events(pw.Schema):\n    ts: pw.DateTimeUtc  # or pw.DateTimeNaive","handlingStrategy":"type-guard","validationCode":"import datetime, typing\n\ndef fix_datetime_annotations(ns: dict) -> dict:\n    return {\n        k: (pw.DateTimeUtc if v is datetime.datetime else v)\n        for k, v in ns.items()\n    }","typeGuard":"import datetime\n\ndef is_pathway_dtype(tp) -> bool:\n    return tp is not datetime.datetime  # use in schema builders before declaring fields","tryCatchPattern":null,"preventionTips":["Always declare datetimes as pw.DateTimeUtc or pw.DateTimeNaive in schemas","Decide timezone semantics up front: tz-aware -> DateTimeUtc, naive -> DateTimeNaive","Run a tiny schema-definition unit test in CI so annotations are checked at import time"],"tags":["pathway","dtype","datetime","schema","type-system"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}