Skip to content

Commit

Permalink
add test for suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
raisadz committed Jan 24, 2025
1 parent 1e2ce0e commit 069d4f9
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/frame/join_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,36 @@ def test_joinasof_by(
assert_equal_data(result_by.sort(by="antananarivo"), expected)


def test_joinasof_suffix(
constructor: Constructor,
request: pytest.FixtureRequest,
) -> None:
if any(x in str(constructor) for x in ("pyarrow_table", "cudf", "pyspark")):
request.applymarker(pytest.mark.xfail)
if PANDAS_VERSION < (2, 1) and (
("pandas_pyarrow" in str(constructor)) or ("pandas_nullable" in str(constructor))
):
request.applymarker(pytest.mark.xfail)
df = nw.from_native(
constructor({"antananarivo": [1, 5, 10], "val": ["a", "b", "c"]})
).sort("antananarivo")
df_right = nw.from_native(
constructor({"antananarivo": [1, 2, 3, 6, 7], "val": [1, 2, 3, 6, 7]})
).sort("antananarivo")
result = df.join_asof(
df_right, # type: ignore[arg-type]
left_on="antananarivo",
right_on="antananarivo",
suffix="_y",
)
expected = {
"antananarivo": [1, 5, 10],
"val": ["a", "b", "c"],
"val_y": [1, 3, 7],
}
assert_equal_data(result.sort(by="antananarivo"), expected)


@pytest.mark.parametrize("strategy", ["back", "furthest"])
def test_joinasof_not_implemented(
constructor: Constructor, strategy: Literal["backward", "forward"]
Expand Down

0 comments on commit 069d4f9

Please sign in to comment.