Skip to content

Commit d78f060

Browse files
committed
fix: asof_join for columns with different names
closes #11780
1 parent 6459497 commit d78f060

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

ibis/backends/tests/test_asof_join.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ def test_keyed_asof_join(
219219
@pytest.mark.parametrize(
220220
("direction", "op"), [("backward", operator.ge), ("forward", operator.le)]
221221
)
222+
@pytest.mark.parametrize("right_column_key", [None, "on_right_time"])
222223
@pytest.mark.notimpl(
223224
["clickhouse"], raises=AssertionError, reason="`time` is truncated to seconds"
224225
)
@@ -251,8 +252,15 @@ def test_keyed_asof_join_with_tolerance(
251252
time_keyed_df2,
252253
direction,
253254
op,
255+
right_column_key,
254256
):
255-
on = op(time_keyed_left["time"], time_keyed_right["time"])
257+
left_key = right_key = "time"
258+
if right_column_key:
259+
right_key = right_column_key
260+
time_keyed_right = time_keyed_right.rename({right_column_key: "time"})
261+
assert left_key != right_key
262+
263+
on = op(time_keyed_left[left_key], time_keyed_right[right_key])
256264
expr = time_keyed_left.asof_join(
257265
time_keyed_right, on, "key", tolerance=ibis.interval(days=2)
258266
)

ibis/expr/types/joins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def asof_join(
323323
filtered = joined.filter(
324324
left_on <= right_on + tolerance, left_on >= right_on - tolerance
325325
)
326-
right_on = right_on.op().replace({right.op(): filtered.op()}).to_expr()
326+
(right_on,) = filtered.bind(left_on)
327327

328328
# without joining twice the table would not contain the rows from
329329
# the left table that do not match any row from the right table

0 commit comments

Comments
 (0)