pathwaycom/pathway · error · TypeError

Unsupported type {input_type}, use pw.DATE_TIME_UTC or pw.DA

Error message

Unsupported type {input_type}, use pw.DATE_TIME_UTC or pw.DATE_TIME_NAIVE

What it means

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.

Source

Thrown at python/pathway/internals/dtype.py:741

    elif input_type == np.ndarray:
        return ANY_ARRAY
    elif typing.get_origin(input_type) == np.ndarray:
        dims, wrapped = typing.get_args(input_type)
        dims_args = typing.get_args(dims)
        if dims == typing.Any or (dims_args and dims_args[-1] is ...):
            # tuple[X, ...] shapes (used by NDArray on numpy >= 2.1) leave the
            # number of dimensions unspecified, same as the older Any shape
            return Array(n_dim=None, wrapped=wrap(wrapped))
        return Array(n_dim=len(dims_args), wrapped=wrap(wrapped))
    elif input_type == api.PyObjectWrapper:
        return ANY_PY_OBJECT_WRAPPER
    elif typing.get_origin(input_type) == api.PyObjectWrapper:
        (inner,) = typing.get_args(input_type)
        return PyObjectWrapper(inner)
    elif isinstance(input_type, type) and issubclass(input_type, Enum):
        return ANY
    elif input_type == datetime.datetime:
        raise TypeError(
            f"Unsupported type {input_type}, use pw.DATE_TIME_UTC or pw.DATE_TIME_NAIVE"
        )
    elif input_type == datetime.timedelta:
        raise TypeError(f"Unsupported type {input_type}, use pw.DURATION")
    elif typing.get_origin(input_type) == asyncio.Future:
        args = get_args(input_type)
        (arg,) = args
        return Future(wrap(arg))
    else:
        dtype = {
            int: INT,
            bool: BOOL,
            str: STR,
            float: FLOAT,
            datetime_types.Duration: DURATION,
            datetime_types.DateTimeNaive: DATE_TIME_NAIVE,
            datetime_types.DateTimeUtc: DATE_TIME_UTC,
            np.int32: INT,

View on GitHub (pinned to fa2f74a464)

Solutions

  1. Use pw.DateTimeUtc (pw.DATE_TIME_UTC) if values carry timezone info (e.g. pandas tz-aware or ISO strings with offset)
  2. Use pw.DateTimeNaive (pw.DATE_TIME_NAIVE) if values have no timezone component
  3. If you truly need arbitrary python objects, use pw.PyObjectWrapper (pw.Any) instead of datetime.datetime

Example fix

// before
import datetime
class Events(pw.Schema):
    ts: datetime.datetime
// after
class Events(pw.Schema):
    ts: pw.DateTimeUtc  # or pw.DateTimeNaive
Defensive patterns

Strategy: type-guard

Validate before calling

import datetime, typing

def fix_datetime_annotations(ns: dict) -> dict:
    return {
        k: (pw.DateTimeUtc if v is datetime.datetime else v)
        for k, v in ns.items()
    }

Type guard

import datetime

def is_pathway_dtype(tp) -> bool:
    return tp is not datetime.datetime  # use in schema builders before declaring fields

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15). Data as JSON: /api/errors/d4893d99fcad2a73. Report an issue: GitHub.