Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce version file so we can conditionally handle things in tests #16280

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
wence- marked this conversation as resolved.
Show resolved Hide resolved
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
wence- marked this conversation as resolved.
Show resolved Hide resolved
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
Loading