Skip to content

Commit

Permalink
Fix tuples as on argument in merge (#1117)
Browse files Browse the repository at this point in the history
  • Loading branch information
phofl authored Aug 12, 2024
1 parent 9c12ceb commit 5cee29b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions dask_expr/_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5658,6 +5658,11 @@ def merge(
if on and not left_on and not right_on:
left_on = right_on = on

if pd.api.types.is_list_like(left_on) and not isinstance(left_on, FrameBase):
left_on = list(left_on)
if pd.api.types.is_list_like(right_on) and not isinstance(right_on, FrameBase):
right_on = list(right_on)

supported_how = ("left", "right", "outer", "inner", "leftsemi")
if how not in supported_how:
raise ValueError(
Expand Down
21 changes: 21 additions & 0 deletions dask_expr/tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,3 +1029,24 @@ def test_merge_after_rename(index):
expected = pleft.merge(right, how="inner")
result = left.merge(right, how="inner")
assert_eq(result, expected, check_index=False)


def test_merge_tuple_left_on():
df = pd.DataFrame(
{
"a": [1, 2, 3] * 5,
"b": [1, 2, 3] * 5,
"c": ["A"] * 15,
},
)
ddf = from_pandas(df, npartitions=2)
assert_eq(
ddf.merge(ddf, left_on=("a",), right_on=("a",)),
df.merge(df, left_on=("a",), right_on=("a",)),
check_index=False,
)
assert_eq(
ddf.merge(ddf, on=("a",)),
df.merge(df, on=("a",)),
check_index=False,
)
2 changes: 1 addition & 1 deletion dask_expr/tests/test_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_resample_divisions_propagation():
pdf = pd.DataFrame({"data": 1}, index=idx)
df = from_pandas(pdf, npartitions=10)
result = df.resample("0.03s").mean()
result = result.repartition(freq="1T")
result = result.repartition(freq="1d")
expected = pdf.resample("0.03s").mean()
assert_eq(result, expected)

Expand Down

0 comments on commit 5cee29b

Please sign in to comment.