pathwaycom/pathway · error · ValueError
The boolean condition is not properly ordered. The left part
Error message
The boolean condition is not properly ordered. The 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).
What it means
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.
Source
Thrown at python/pathway/internals/joins.py:1153
def validate_join_condition(
cond: expr.ColumnExpression, left: Table, right: Table
) -> tuple[expr.ColumnReference, expr.ColumnReference, expr.ColumnBinaryOpExpression]:
cond = validate_shape(cond)
try:
eval_type(cond)
except TypeError:
raise TypeError(
"Incompatible types in a join condition.\n"
+ f"The types are: {eval_type(cond._left)} and {eval_type(cond._right)}. "
+ "You might try casting the respective columns to Any type to circumvent this,"
+ " but this is most probably an error."
)
cond_left = cast(expr.ColumnReference, cond._left)
cond_right = cast(expr.ColumnReference, cond._right)
if cond_left.table == right and cond_right.table == left:
raise ValueError(
"The boolean condition is not properly ordered.\n"
+ "The 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)."
)
if cond_left.table != left:
raise ValueError(
"Left part of a join condition has to be a reference to a table "
+ "on the left side of a join"
)
if cond_right.table != right:
raise ValueError(
"Right part of a join condition has to be a reference to a table "
+ "on the right side of a join"
)
return cond_left, cond_right, cond
def join(View on GitHub (pinned to fa2f74a464)
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 ==
Example fix
# before res = t1.join(t2, t2.owner == t1.owner) # after res = t1.join(t2, t1.owner == t2.owner)
Defensive patterns
Strategy: validation
Validate before calling
def ordered_condition(left_table, right_table, cond):
return not (cond._left.table == right_table and cond._right.table == left_table)
# build conditions from the left table's side: t1.join(t2, t1.x == t2.y) Prevention
- Write join conditions left-to-right matching the join call order
- In code generators, template the condition with the left joinable's reference first
When it happens
Trigger: t1.join(t2, t2.foo == t1.bar) — both references present but each side references the opposite joinable.
Common situations: Reordering join arguments during refactors; generated join conditions built from the right table's perspective.
Related errors
- join condition should be of form <left_table>.<column> == <r
- Left part of a join condition has to be a reference to a tab
- Right part of a join condition has to be a reference to a ta
- Join received extra kwargs. You probably want to use TableLi
- Cannot assign id's for this join type.
AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15).
Data as JSON: /api/errors/86c349087eaaa80f.
Report an issue: GitHub.