arrow icon indicating copy to clipboard operation
arrow copied to clipboard

[Python] Fix deprecation warnings for RankOptions null_placement in our own tests

Open jorisvandenbossche opened this issue 2 months ago • 6 comments

In the test logs on CI, I see:

opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_option_class_equality
  /opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py:175: FutureWarning: Specifying null_placement in RankOptions is deprecated as of 25.0.0. Specify null_placement per sort_key instead.
    pc.RankOptions(sort_keys="ascending",

opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_option_class_equality
  /opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py:177: FutureWarning: Specifying null_placement in RankOptions is deprecated as of 25.0.0. Specify null_placement per sort_key instead.
    pc.RankQuantileOptions(sort_keys="ascending",

opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_rank_options_tiebreaker[min-expected_values0]
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_rank_options_tiebreaker[max-expected_values1]
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_rank_options_tiebreaker[first-expected_values2]
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_rank_options_tiebreaker[dense-expected_values3]
  /opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py:3885: FutureWarning: Specifying null_placement in RankOptions is deprecated as of 25.0.0. Specify null_placement per sort_key instead.
    rank_options = pc.RankOptions(sort_keys="ascending",

opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_rank_options
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_rank_quantile_options
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_rank_normal_options
  /opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/compute.py:230: FutureWarning: Specifying null_placement in RankOptions is deprecated as of 25.0.0. Specify null_placement per sort_key instead.
    return options_class(*args, **kwargs)

opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_rank_options
  /opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py:3921: FutureWarning: Specifying null_placement in RankOptions is deprecated as of 25.0.0. Specify null_placement per sort_key instead.
    pc.RankOptions(sort_keys="descending",

opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_rank_normal_options
  /opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py:3975: FutureWarning: Specifying null_placement in RankOptions is deprecated as of 25.0.0. Specify null_placement per sort_key instead.
    options=pc.RankQuantileOptions(null_placement="at_start",

Those warnings should not appear in our own tests (either update the tests to use the new pattern, or explicitly assert that the warning is happening)

jorisvandenbossche avatar Sep 11 '26 08:09 jorisvandenbossche

Caused by https://github.com/apache/arrow/pull/46926 cc @taepper

jorisvandenbossche avatar Sep 11 '26 08:09 jorisvandenbossche

I see. Yes, this is unfortunate. We can remove the tests using the deprecated interface to avoid this warning. I left them in the PR because I thought it is still good to have test coverage for deprecated functionality.

taepper avatar Sep 11 '26 08:09 taepper

If what is being tested in those tests is covered by new tests (using the new interface), but we want to keep them to ensure this deprecated path is still working (which is indeed a good idea), then we can just suppress the warnings with a @pytest.mark.filterwarnings("ignore:...")

jorisvandenbossche avatar Sep 11 '26 08:09 jorisvandenbossche

Great, thanks. I am not an expert in python and only adapted the interfaces when changing the underlying c++ interfaces.

taepper avatar Sep 11 '26 08:09 taepper

take

taepper avatar Sep 11 '26 08:09 taepper

Issue resolved by pull request 51307 https://github.com/apache/arrow/pull/51307

AlenkaF avatar Sep 25 '26 08:09 AlenkaF