pathwaycom/pathway · error · ValueError
Right part of a join condition has to be a reference to a ta
Error message
Right part of a join condition has to be a reference to a table on the right side of a join
What it means
Final check in validate_join_condition: cond_right.table must equal the right joinable; otherwise ValueError 'Right part of a join condition has to be a reference to a table on the right side of a join'. Catches conditions whose right operand references the left table again or an unrelated table (left-side misuse is caught by 97/98 first).
Source
Thrown at python/pathway/internals/joins.py:1164
+ 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(
left: Joinable,
right: Joinable,
*on: expr.ColumnExpression,
id: expr.ColumnReference | None = None,
how: JoinMode = JoinMode.INNER,
left_instance: expr.ColumnReference | None = None,
right_instance: expr.ColumnReference | None = None,
left_exactly_once: bool = False,
right_exactly_once: bool = False,
) -> JoinResult:
"""Join self with other using the given join expression.View on GitHub (pinned to fa2f74a464)
Solutions
- Point the right operand at the right joinable: t1.join(t2, t1.a == t2.a)
- For a same-table comparison use filter()/where instead of join
- Chain joins when more than two tables are involved
Example fix
# before res = t1.join(t2, t1.a == t1.b) # after res = t1.join(t2, t1.a == t2.a)
Defensive patterns
Strategy: validation
Validate before calling
def right_ref_ok(right, cond) -> bool:
return cond._right.table == right
assert right_ref_ok(t2, t1.k == t2.k) Prevention
- Each side of == must reference its own joinable; same-table comparisons belong in where()/filter()
- Chain multi-table joins rather than referencing a third table in one condition
When it happens
Trigger: t1.join(t2, t1.a == t1.b) — both sides reference the left table; or t1.join(t2, t1.a == t3.b).
Common situations: Copy-pasting a condition and changing only one side; self-comparisons intended as filters rather than join keys; stale variables after renaming join inputs.
Related errors
- join condition should be of form <left_table>.<column> == <r
- The boolean condition is not properly ordered. The left part
- Left part of a join condition has to be a reference to a tab
- 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/1d9aee3cf4a70eaf.
Report an issue: GitHub.