Skip to content

Commit

Permalink
chore: handle joins with no user-provided predicates
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Dec 26, 2023
1 parent ff35399 commit 9b4c739
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 1 addition & 2 deletions ibis/backends/base/sqlglot/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,8 +924,7 @@ def visit_JoinLink(self, op, *, how, table, predicates):
"cross": "cross",
"outer": "outer",
}
if not predicates:
predicates += (True,)
assert predicates
return sge.Join(
this=table, side=sides[how], kind=kinds[how], on=sg.and_(*predicates)
)
Expand Down
5 changes: 5 additions & 0 deletions ibis/expr/types/joins.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ def join(
)
preds = flatten_predicates(list(preds))

# if there are no predicates, default to every row matching unless the
# join is a cross join, because a cross join already has this behavior
if not preds and how != "cross":
preds.append(ops.Literal(True, dtype="bool"))

# calculate the fields based in lname and rname, this should be a best
# effort to avoid collisions, but does not raise if there are any
# if no disambiaution happens using a final .select() call, then
Expand Down

0 comments on commit 9b4c739

Please sign in to comment.