pathwaycom/pathway · error · TypeError
Pathway does not support using binary operator {operator.__n
Error message
Pathway does not support using binary operator {operator.__name__} on columns of types {original_left.typehint}, {original_right.typehint}.\nIt refers to the following expression:\n{expression_info} What it means
Raised by the type interpreter when a binary operator (e.g. +, *, ==, &) is applied to column types for which Pathway defines no combined operation. The interpreter checks the left/right dtypes (including tuple/list element-wise rules); on failure it reports the operator, both original typehints, and the expression trace so the offending line can be located.
Source
Thrown at python/pathway/internals/type_interpreter.py:151
return dtype
left_dtype, right_dtype = dt.unoptionalize_pair(left_dtype, right_dtype)
if (
dtype_and_handler := get_binary_operators_mapping_optionals(
operator, left_dtype, right_dtype
)
) is not None:
return dtype_and_handler[0]
maybe_dtype = self._eval_binary_op_on_tuples(
left_dtype, right_dtype, operator, expression
)
if maybe_dtype is not None:
return maybe_dtype
expression_info = get_expression_info(expression)
raise TypeError(
f"Pathway does not support using binary operator {operator.__name__}"
+ f" on columns of types {original_left.typehint}, {original_right.typehint}.\n"
+ "It refers to the following expression:\n"
+ expression_info
)
def _eval_binary_op_on_tuples(
self,
left_dtype: dt.DType,
right_dtype: dt.DType,
operator: Any,
expression: expr.ColumnExpression,
) -> dt.DType | None:
if (
isinstance(left_dtype, (dt.Tuple, dt.List))
and isinstance(right_dtype, (dt.Tuple, dt.List))
and operator in tuple_handling_operators
):View on GitHub (pinned to fa2f74a464)
Solutions
- Cast the operands to compatible types before the operation: pw.this.col.astype(float) + pw.this.other.astype(float)
- Ensure connector dtypes are correct: declare proper types in the input Schema (int, float) instead of relying on inferred str
- For Optional columns, apply unwrap or replace None defaults first so both sides have concrete dtypes
- If the mix is intentional, cast both sides to Any (pw.cast_to(Any)) to defer typing — last resort as it removes safety
Example fix
# before result = table.select(total=pw.this.price * pw.this.amount) # str * int unsupported # after result = table.select(total=pw.this.price.astype(float) * pw.this.amount.astype(int))
Defensive patterns
Strategy: type-guard
Validate before calling
import pathway as pw
def dtypes_compatible(l, r) -> bool:
"""Cheap check: both numeric, both str, or equal types."""
num = lambda t: t in (pw.typehints.Int(), pw.typehints.Float())
return (num(l) and num(r)) or l.equivalent_to(r) Type guard
def both_numeric(l, r) -> bool:
import pathway as pw
num = lambda t: t in (pw.typehints.Int(), pw.typehints.Float())
return num(l) and num(r) Try / catch
try:
out = t.select(v=pw.this.a * pw.this.b)
except TypeError:
out = t.select(v=pw.this.a.astype(float) * pw.this.b.astype(float)) Prevention
- Declare explicit types in every input Schema; never let numeric fields default to str
- Cast operands with astype at the boundary right after ingestion
- Validate sample rows (pw.debug.compute_and_print) before building large graphs
When it happens
Trigger: pw.this.quantity * pw.this.label where one is int and the other str; comparing incompatible types like pw.this.date_col == pw.this.id with mixed types; arithmetic between str and int columns; mixing bool with int under operators Pathway does not map for that pair.
Common situations: CSV/JSON ingestion where everything arrives as str or Any and users do arithmetic immediately; comparing a DateTime column to a plain str literal; Optional columns combined with plain columns without unwrapping; pandas-to-Pathway ports relying on implicit coercion.
Related errors
- Pathway does not support using unary operator {operator_fun.
- Cannot change type from {right} to {left}.\npw.`declare_type
- Incompatible types in for a coalesce expression.\nThe types
- Cannot perform pathway.if_else on columns of types {then_dty
- Pathway does not support using binary operator {expression._
AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15).
Data as JSON: /api/errors/7f7e004c6f4d9a11.
Report an issue: GitHub.