{"record":{"id":"dd4db038d6549a99","repo":"pathwaycom/pathway","slug":"type-has-to-be-either-timeeventtype-or-intervaltyp","errorCode":null,"errorMessage":"Type has to be either TimeEventType or IntervalType.","messagePattern":"Type has to be either TimeEventType or IntervalType\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/stdlib/temporal/utils.py","lineNumber":43,"sourceCode":"\n\ndef zero_length_interval(interval_type: type[IntervalType]) -> IntervalType:\n    if issubclass(interval_type, datetime.timedelta):\n        return datetime.timedelta(0)\n    elif issubclass(interval_type, int):\n        return 0\n    elif issubclass(interval_type, float):\n        return 0.0\n    else:\n        raise Exception(\"unsupported interval type\")\n\n\ndef _get_possible_types(type: Any) -> tuple[dt.DType, ...]:\n    if type is TimeEventType:\n        return (dt.INT, dt.FLOAT, dt.DATE_TIME_NAIVE, dt.DATE_TIME_UTC)\n    if type is IntervalType:\n        return (dt.INT, dt.FLOAT, dt.DURATION, dt.DURATION)\n    raise ValueError(\"Type has to be either TimeEventType or IntervalType.\")\n\n\ndef check_joint_types(parameters: dict[str, tuple[Any, Any]]) -> None:\n    \"\"\"Checks if all parameters have types that allow to execute a function.\n    If parameters are {'a': (a, TimeEventType), 'b': (b, IntervalType)} then\n    the following pairs of types are allowed for (a, b): (int, int), (float, float),\n    (datetime.datetime, datetime.timedelta)\n    \"\"\"\n\n    parameters = {\n        name: (variable, expected_type)\n        for name, (variable, expected_type) in parameters.items()\n        if variable is not None\n    }\n    types = {name: eval_type(variable) for name, (variable, _) in parameters.items()}\n    expected_types = []\n    for i in range(len(_get_possible_types(TimeEventType))):\n        expected_types.append(","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/stdlib/temporal/utils.py#L25-L61","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"# before\ncheck_joint_types({'t': (ts_col, dt.DATE_TIME_NAIVE)})\n\n# after\nfrom pathway.stdlib.temporal.types import TimeEventType\ncheck_joint_types({'t': (ts_col, TimeEventType)})","handlingStrategy":"type-guard","validationCode":"from pathway.stdlib.temporal.types import TimeEventType, IntervalType\nassert expected_type in (TimeEventType, IntervalType), 'expected_type must be a temporal sentinel type'","typeGuard":"def is_temporal_marker(t: Any) -> bool:\n    from pathway.stdlib.temporal.types import TimeEventType, IntervalType\n    return t is TimeEventType or t is IntervalType","tryCatchPattern":"try:\n    check_joint_types(params)\nexcept ValueError as e:\n    if 'TimeEventType or IntervalType' in str(e):\n        raise ValueError(f'Bad temporal marker in {params.keys()}') from e\n    raise","preventionTips":["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"],"tags":["pathway","temporal","type-check","argument-validation"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}