{"record":{"id":"bf11f56c4c13a99f","repo":"pathwaycom/pathway","slug":"pathway-does-not-support-using-binary-operator-ex","errorCode":null,"errorMessage":"Pathway does not support using binary operator {expression._operator.__name__} on columns of types {left_dtype}, {right_dtype}.It refers to the following expression:\n{expression_info}","messagePattern":"Pathway does not support using binary operator (.+?) on columns of types (.+?), (.+?)\\.It refers to the following expression:\n(.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/graph_runner/expression_evaluator.py","lineNumber":413,"sourceCode":"            )\n        ) is not None:\n            return result_expression\n\n        left_dtype_unoptionalized, right_dtype_unoptionalized = dt.unoptionalize_pair(\n            left_dtype,\n            right_dtype,\n        )\n\n        if (\n            dtype_and_handler := get_binary_operators_mapping_optionals(\n                operator_fun, left_dtype_unoptionalized, right_dtype_unoptionalized\n            )\n        ) is not None:\n            return dtype_and_handler[1](left, right)\n\n        expression_info = get_expression_info(expression)\n        # this path should be covered by TypeInterpreter\n        raise TypeError(\n            f\"Pathway does not support using binary operator {expression._operator.__name__}\"\n            + f\" on columns of types {left_dtype}, {right_dtype}.\"\n            + \"It refers to the following expression:\\n\"\n            + expression_info\n        )\n\n    def eval_const(\n        self,\n        expression: expr.ColumnConstExpression,\n        eval_state: RowwiseEvalState | None = None,\n    ):\n        return api.Expression.const(expression._val, expression._dtype.to_engine())\n\n    def eval_call(\n        self,\n        expression: expr.ColumnCallExpression,\n        eval_state: RowwiseEvalState | None = None,\n    ):","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/graph_runner/expression_evaluator.py#L395-L431","documentation":"When lowering a binary operator expression (+, -, *, <, ==, ...) to an engine call, the evaluator looks up a handler for the (operator, left dtype, right dtype) triple — after unwrapping Optionals. If none is registered, it raises this TypeError with the operator and both dtypes. Normally the earlier TypeInterpreter catches this, so seeing it means static typing was bypassed (e.g. via pw.cast/declare or Any-typed intermediates).","triggerScenarios":"Adding str + int columns; comparing a DateTimeNaive with a DateTimeUtc; arithmetic on Json/Any-typed columns whose real runtime dtypes have no handler; mixing bytes and str; operations between Pointer and int after casting away types.","commonSituations":"Columns left as pw.Json or Any from dynamic sources, then used in arithmetic; casts that lie about the true dtype; schema drift where a column silently changed type; datetime arithmetic mixing naive and UTC columns.","solutions":["Match the dtypes named in the message: cast one side explicitly (pw.this.a.cast(int)) or fix the schema so both operands are types the operator supports","For Json/Any columns, first extract and convert to a concrete dtype (pw.Json[...] accessors, .astype-like selects) before applying the operator","Wrap risky combinations in pw.if_else/t.try_else so incompatible rows degrade gracefully instead of failing the pipeline"],"exampleFix":"// before\nresult = pw.this.quantity * pw.this.price  # price is pw.Json / Any\n// after\nresult = pw.this.quantity * pw.this.price.as_float()","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"SUPPORTED_ADD = {(int, int), (int, float), (float, float), (str, str)}\n\ndef binary_op_supported(op, left_dtype, right_dtype) -> bool:\n    return (type(left_dtype), type(right_dtype)) in SUPPORTED_ADD or str(left_dtype) == str(right_dtype) == 'ANY' is False","tryCatchPattern":"try:\n    table.select(s=pw.this.a * pw.this.b)\nexcept TypeError as e:\n    if \"does not support using binary operator\" in str(e):\n        # add explicit casts / converters for the named dtypes and rebuild\n        ...","preventionTips":["Apply operators only between matching, concrete dtypes; cast explicitly first","Extract concrete types from Json/Any columns before arithmetic or comparisons","Avoid mixing DateTimeNaive and DateTimeUtc columns in one expression"],"tags":["pathway","binary-operator","dtype","type-mismatch","expression"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}