Skip to content

Commit

Permalink
Introduce version file so we can conditionally handle things in tests (
Browse files Browse the repository at this point in the history
…#16280)

We decided we would attempt to support a range of versions back to 1.0. We'll test with oldest and newest versions we support. To facilitate, introduce some versioning constants.

Authors:
  - Lawrence Mitchell (https://github.com/wence-)

Approvers:
  - Thomas Li (https://github.com/lithomas1)

URL: #16280
  • Loading branch information
wence- authored Jul 16, 2024
1 parent 669db3e commit a6de6cc
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
7 changes: 6 additions & 1 deletion python/cudf_polars/cudf_polars/dsl/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,12 @@ def evaluate(self, *, cache: MutableMapping[int, DataFrame]) -> DataFrame:
raise NotImplementedError(
f"Unhandled scan type: {self.typ}"
) # pragma: no cover; post init trips first
if row_index is not None:
if (
row_index is not None
# TODO: remove condition when dropping support for polars 1.0
# https://github.com/pola-rs/polars/pull/17363
and row_index[0] in self.schema
):
name, offset = row_index
dtype = self.schema[name]
step = plc.interop.from_arrow(
Expand Down
28 changes: 28 additions & 0 deletions python/cudf_polars/cudf_polars/utils/versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES.
# SPDX-License-Identifier: Apache-2.0

"""Version utilities so that cudf_polars supports a range of polars versions."""

# ruff: noqa: SIM300
from __future__ import annotations

from packaging.version import parse

from polars import __version__

POLARS_VERSION = parse(__version__)

POLARS_VERSION_GE_10 = POLARS_VERSION >= parse("1.0")
POLARS_VERSION_GE_11 = POLARS_VERSION >= parse("1.1")
POLARS_VERSION_GE_12 = POLARS_VERSION >= parse("1.2")
POLARS_VERSION_GT_10 = POLARS_VERSION > parse("1.0")
POLARS_VERSION_GT_11 = POLARS_VERSION > parse("1.1")
POLARS_VERSION_GT_12 = POLARS_VERSION > parse("1.2")

POLARS_VERSION_LE_12 = POLARS_VERSION <= parse("1.2")
POLARS_VERSION_LE_11 = POLARS_VERSION <= parse("1.1")
POLARS_VERSION_LT_12 = POLARS_VERSION < parse("1.2")
POLARS_VERSION_LT_11 = POLARS_VERSION < parse("1.1")

if POLARS_VERSION < parse("1.0"): # pragma: no cover
raise ImportError("cudf_polars requires py-polars v1.0 or greater.")
5 changes: 5 additions & 0 deletions python/cudf_polars/tests/test_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
assert_gpu_result_equal,
assert_ir_translation_raises,
)
from cudf_polars.utils import versions


@pytest.fixture(
Expand Down Expand Up @@ -97,6 +98,10 @@ def test_scan_unsupported_raises(tmp_path):
assert_ir_translation_raises(q, NotImplementedError)


@pytest.mark.xfail(
versions.POLARS_VERSION_LT_11,
reason="https://github.com/pola-rs/polars/issues/15730",
)
def test_scan_row_index_projected_out(tmp_path):
df = pl.DataFrame({"a": [1, 2, 3]})

Expand Down

0 comments on commit a6de6cc

Please sign in to comment.