pathwaycom/pathway · error · ValueError
Type has to be either TimeEventType or IntervalType.
Error message
Type has to be either TimeEventType or IntervalType.
What it means
Raised by _get_possible_types in pathway.stdlib.temporal.utils, which maps an 'expected type' marker (TimeEventType for time instants, IntervalType for durations) to the set of dtypes a temporal stdlib function accepts. If the marker passed to the joint type check is anything other than these two sentinel classes, the function cannot determine the allowed dtype combinations and raises ValueError. It is essentially an argument-contract error for the temporal helper API, not a data error.
Source
Thrown at python/pathway/stdlib/temporal/utils.py:43
def zero_length_interval(interval_type: type[IntervalType]) -> IntervalType:
if issubclass(interval_type, datetime.timedelta):
return datetime.timedelta(0)
elif issubclass(interval_type, int):
return 0
elif issubclass(interval_type, float):
return 0.0
else:
raise Exception("unsupported interval type")
def _get_possible_types(type: Any) -> tuple[dt.DType, ...]:
if type is TimeEventType:
return (dt.INT, dt.FLOAT, dt.DATE_TIME_NAIVE, dt.DATE_TIME_UTC)
if type is IntervalType:
return (dt.INT, dt.FLOAT, dt.DURATION, dt.DURATION)
raise ValueError("Type has to be either TimeEventType or IntervalType.")
def check_joint_types(parameters: dict[str, tuple[Any, Any]]) -> None:
"""Checks if all parameters have types that allow to execute a function.
If parameters are {'a': (a, TimeEventType), 'b': (b, IntervalType)} then
the following pairs of types are allowed for (a, b): (int, int), (float, float),
(datetime.datetime, datetime.timedelta)
"""
parameters = {
name: (variable, expected_type)
for name, (variable, expected_type) in parameters.items()
if variable is not None
}
types = {name: eval_type(variable) for name, (variable, _) in parameters.items()}
expected_types = []
for i in range(len(_get_possible_types(TimeEventType))):
expected_types.append(View on GitHub (pinned to fa2f74a464)
Solutions
- Pass exactly pathway.stdlib.temporal.types.TimeEventType or IntervalType as the expected_type marker (identity matters: `is`, not issubclass)
- If you called check_joint_types directly, review its docstring: each entry must be a (column, TimeEventType|IntervalType) pair
- If you genuinely need a new category, extend _get_possible_types in a fork and add the allowed dtype tuple, then raise upstream
Example fix
# before
check_joint_types({'t': (ts_col, dt.DATE_TIME_NAIVE)})
# after
from pathway.stdlib.temporal.types import TimeEventType
check_joint_types({'t': (ts_col, TimeEventType)}) Defensive patterns
Strategy: type-guard
Validate before calling
from pathway.stdlib.temporal.types import TimeEventType, IntervalType assert expected_type in (TimeEventType, IntervalType), 'expected_type must be a temporal sentinel type'
Type guard
def is_temporal_marker(t: Any) -> bool:
from pathway.stdlib.temporal.types import TimeEventType, IntervalType
return t is TimeEventType or t is IntervalType Try / catch
try:
check_joint_types(params)
except ValueError as e:
if 'TimeEventType or IntervalType' in str(e):
raise ValueError(f'Bad temporal marker in {params.keys()}') from e
raise Prevention
- Never substitute dtypes or Python types for TimeEventType/IntervalType markers
- When wrapping temporal stdlib functions, forward the sentinel types unchanged
- Pin the Pathway version if you import the sentinel classes from internal modules
When it happens
Trigger: Calling pathway.stdlib.temporal functions that run check_joint_types (e.g. interval joins / asof-style operations) with a custom or wrong third element in the (value, expected_type) pairs; directly calling check_joint_types({'t': (col, SomeOtherClass)}); passing a subclass or a dtype instance instead of the exact TimeEventType/IntervalType sentinels (the check uses `is`, not issubclass).
Common situations: Extending or wrapping pathway.stdlib.temporal internals without using the sentinel types; copying internal call sites across Pathway versions where the sentinel classes were renamed/moved; passing dt.INT/dt.FLOAT or python types (int, datetime) where the API marker is expected.
Related errors
- The behavior argument of join should be of type pathway.temp
- Arguments ({', '.join(parameters.keys())}) have to be of typ
- direction argument of join should be of type asof_join.Direc
- The interval argument of a join should be of a type pathway.
- Join received extra kwargs. You probably want to use TableLi
AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15).
Data as JSON: /api/errors/dd4db038d6549a99.
Report an issue: GitHub.