Skip to content

Commit

Permalink
Raise early on unhandled PythonScan node (#15992)
Browse files Browse the repository at this point in the history
Add test of the behaviour.

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

Approvers:
  - Bradley Dice (https://github.com/bdice)

URL: #15992
  • Loading branch information
wence- authored Jun 13, 2024
1 parent 8bbc512 commit af09d3e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/cudf_polars/cudf_polars/dsl/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ class PythonScan(IR):
predicate: expr.NamedExpr | None
"""Filter to apply to the constructed dataframe before returning it."""

def __post_init__(self):
"""Validate preconditions."""
raise NotImplementedError("PythonScan not implemented")


@dataclasses.dataclass(slots=True)
class Scan(IR):
Expand Down
20 changes: 20 additions & 0 deletions python/cudf_polars/tests/test_python_scan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES.
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations

import pytest

import polars as pl

from cudf_polars import translate_ir


def test_python_scan():
def source(with_columns, predicate, nrows):
return pl.DataFrame({"a": pl.Series([1, 2, 3], dtype=pl.Int8())})

q = pl.LazyFrame._scan_python_function({"a": pl.Int8}, source, pyarrow=False)
with pytest.raises(NotImplementedError):
_ = translate_ir(q._ldf.visit())

assert q.collect().equals(source(None, None, None))

0 comments on commit af09d3e

Please sign in to comment.