From cb36fc531d9826b4e5a8e794d7a2b43415540129 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Fri, 25 Feb 2022 06:57:57 -0500 Subject: [PATCH] feat: implement semi/anti join for the pandas backend --- ibis/backends/pandas/execution/join.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ibis/backends/pandas/execution/join.py b/ibis/backends/pandas/execution/join.py index 6e1383912e48..7341a401e98f 100644 --- a/ibis/backends/pandas/execution/join.py +++ b/ibis/backends/pandas/execution/join.py @@ -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