{"record":{"id":"86c349087eaaa80f","repo":"pathwaycom/pathway","slug":"the-boolean-condition-is-not-properly-ordered-the","errorCode":null,"errorMessage":"The boolean condition is not properly ordered.\nThe left part should refer to left joinable and the right one should refer to the right joinable, e.g. t1.join(t2, t1.bar==t2.foo).","messagePattern":"The boolean condition is not properly ordered\\.\nThe left part should refer to left joinable and the right one should refer to the right joinable, e\\.g\\. t1\\.join\\(t2, t1\\.bar==t2\\.foo\\)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/pathway/internals/joins.py","lineNumber":1153,"sourceCode":"\n\ndef validate_join_condition(\n    cond: expr.ColumnExpression, left: Table, right: Table\n) -> tuple[expr.ColumnReference, expr.ColumnReference, expr.ColumnBinaryOpExpression]:\n    cond = validate_shape(cond)\n    try:\n        eval_type(cond)\n    except TypeError:\n        raise TypeError(\n            \"Incompatible types in a join condition.\\n\"\n            + f\"The types are: {eval_type(cond._left)} and {eval_type(cond._right)}. \"\n            + \"You might try casting the respective columns to Any type to circumvent this,\"\n            + \" but this is most probably an error.\"\n        )\n    cond_left = cast(expr.ColumnReference, cond._left)\n    cond_right = cast(expr.ColumnReference, cond._right)\n    if cond_left.table == right and cond_right.table == left:\n        raise ValueError(\n            \"The boolean condition is not properly ordered.\\n\"\n            + \"The left part should refer to left joinable and the right one should refer to the right joinable,\"\n            + \" e.g. t1.join(t2, t1.bar==t2.foo).\"\n        )\n    if cond_left.table != left:\n        raise ValueError(\n            \"Left part of a join condition has to be a reference to a table \"\n            + \"on the left side of a join\"\n        )\n    if cond_right.table != right:\n        raise ValueError(\n            \"Right part of a join condition has to be a reference to a table \"\n            + \"on the right side of a join\"\n        )\n    return cond_left, cond_right, cond\n\n\ndef join(","sourceCodeStart":1135,"sourceCodeEnd":1171,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/internals/joins.py#L1135-L1171","documentation":"validate_join_condition detects a fully swapped condition: cond_left.table == right and cond_right.table == left. The equality is symmetric so the engine could evaluate it, but Pathway requires left-side references on the left for column-name resolution in the result; ValueError tells you to write t1.join(t2, t1.bar==t2.foo) ordering.","triggerScenarios":"t1.join(t2, t2.foo == t1.bar) — both references present but each side references the opposite joinable.","commonSituations":"Reordering join arguments during refactors; generated join conditions built from the right table's perspective.","solutions":["Swap the condition sides: t1.join(t2, t1.bar == t2.foo)","In generated code, emit the condition with the left table's column on the left of =="],"exampleFix":"# before\nres = t1.join(t2, t2.owner == t1.owner)\n\n# after\nres = t1.join(t2, t1.owner == t2.owner)","handlingStrategy":"validation","validationCode":"def ordered_condition(left_table, right_table, cond):\n    return not (cond._left.table == right_table and cond._right.table == left_table)\n\n# build conditions from the left table's side: t1.join(t2, t1.x == t2.y)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write join conditions left-to-right matching the join call order","In code generators, template the condition with the left joinable's reference first"],"tags":["pathway","join","condition","ordering","api-misuse"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}