{"record":{"id":"08d133711436c99b","repo":"pathwaycom/pathway","slug":"unsupported-type-input-type-use-pw-duration","errorCode":null,"errorMessage":"Unsupported type {input_type}, use pw.DURATION","messagePattern":"Unsupported type (.+?), use pw\\.DURATION","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/dtype.py","lineNumber":745,"sourceCode":"        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,\n            np.int64: INT,\n            np.float32: FLOAT,\n            np.float64: FLOAT,\n            bytes: BYTES,","sourceCodeStart":727,"sourceCodeEnd":763,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/dtype.py#L727-L763","documentation":"Pathway represents durations with its own Duration type, not Python's datetime.timedelta, so the dtype translator rejects datetime.timedelta explicitly. The engine needs a first-class Duration dtype to implement arithmetic between datetimes and durations; mapping timedelta silently would break type checking of those operations.","triggerScenarios":"A schema field annotated dt.timedelta / datetime.timedelta; passing timedelta to a dtype-inference API (pw.schema_from_types, column dtypes in connectors) that funnels into the dtype wrapper.","commonSituations":"Modeling interval/elapsed-time columns with the stdlib type out of habit; reusing dataclass annotations as Pathway schemas; UDF return annotations using timedelta.","solutions":["Replace datetime.timedelta with pw.Duration (pw.DURATION) in the schema/annotation","For UDF return types, annotate pw.Duration and convert inside the UDF (e.g. via pw.Duration.duration(...)) instead of returning raw timedelta","If the column just holds arbitrary numeric intervals, consider int/float seconds plus a conversion step"],"exampleFix":"// before\nimport datetime\nclass Sessions(pw.Schema):\n    length: datetime.timedelta\n// after\nclass Sessions(pw.Schema):\n    length: pw.Duration","handlingStrategy":"type-guard","validationCode":"import datetime\n\ndef check_schema_annotations(fields: dict) -> None:\n    for name, tp in fields.items():\n        if tp is datetime.timedelta:\n            raise TypeError(f\"field '{name}': use pw.Duration, not datetime.timedelta\")","typeGuard":"import datetime\n\ndef is_supported_pathway_type(tp) -> bool:\n    return tp is not datetime.timedelta","tryCatchPattern":null,"preventionTips":["Use pw.Duration for all duration/interval schema fields","Convert inside UDFs (annotate return pw.Duration) instead of annotating timedelta","Keep a project-level list of allowed schema annotations and lint against it"],"tags":["pathway","dtype","timedelta","duration","schema"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}