Skip to content

Commit

Permalink
feat: implement semi/anti join for the pandas backend
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored and kszucs committed Mar 2, 2022
1 parent 3e1ba9c commit cb36fc5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions ibis/backends/pandas/execution/join.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,26 @@ def _construct_join_predicate_columns(op, **kwargs):
predicate.right, **kwargs
)
on[right_pred_root].append(new_right_column)
return on[left_op], on[right_op]


@execute_node.register(ops.Join, pd.DataFrame, pd.DataFrame)
def execute_join(op, left, right, **kwargs):
op_type = type(op)

try:
how = constants.JOIN_TYPES[op_type]
except KeyError:
raise NotImplementedError(f'{op_type.__name__} not supported')

left_on, right_on = _construct_join_predicate_columns(op, **kwargs)

df = pd.merge(
left,
right,
how=how,
left_on=on[left_op],
right_on=on[right_op],
left_on=left_on,
right_on=right_on,
suffixes=constants.JOIN_SUFFIXES,
)
return df
Expand Down

0 comments on commit cb36fc5

Please sign in to comment.