From 069d4f93144dbda558c4a274e1611c278c6923b2 Mon Sep 17 00:00:00 2001 From: raisadz <34237447+raisadz@users.noreply.github.com> Date: Fri, 24 Jan 2025 07:53:56 +0000 Subject: [PATCH] add test for suffix --- tests/frame/join_test.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/frame/join_test.py b/tests/frame/join_test.py index 7cbe96fc8..88b5ab678 100644 --- a/tests/frame/join_test.py +++ b/tests/frame/join_test.py @@ -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"]