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

Forward-merge branch-24.08 into branch-24.10 #16396

Merged
merged 1 commit into from
Jul 25, 2024
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
6 changes: 5 additions & 1 deletion python/cudf_polars/cudf_polars/dsl/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,11 @@ class Cast(Expr):
def __init__(self, dtype: plc.DataType, value: Expr) -> None:
super().__init__(dtype)
self.children = (value,)
if not plc.unary.is_supported_cast(self.dtype, value.dtype):
if not (
plc.traits.is_fixed_width(self.dtype)
and plc.traits.is_fixed_width(value.dtype)
and plc.unary.is_supported_cast(value.dtype, self.dtype)
):
raise NotImplementedError(
f"Can't cast {self.dtype.id().name} to {value.dtype.id().name}"
)
Expand Down
14 changes: 13 additions & 1 deletion python/cudf_polars/tests/expressions/test_numeric_binops.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

import polars as pl

from cudf_polars.testing.asserts import assert_gpu_result_equal
from cudf_polars.testing.asserts import (
assert_gpu_result_equal,
assert_ir_translation_raises,
)

dtypes = [
pl.Int8,
Expand Down Expand Up @@ -111,3 +114,12 @@ def test_binop_with_scalar(left_scalar, right_scalar):
q = df.select(lop / rop)

assert_gpu_result_equal(q)


def test_numeric_to_string_cast_fails():
df = pl.DataFrame(
{"a": [1, 1, 2, 3, 3, 4, 1], "b": [None, 2, 3, 4, 5, 6, 7]}
).lazy()
q = df.select(pl.col("a").cast(pl.String))

assert_ir_translation_raises(q, NotImplementedError)
6 changes: 4 additions & 2 deletions python/cudf_polars/tests/expressions/test_stringfunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def ldf(with_nulls):
if with_nulls:
a[4] = None
a[-3] = None
return pl.LazyFrame({"a": a, "b": range(len(a))})
return pl.LazyFrame(
{"a": a, "b": range(len(a)), "c": [str(i) for i in range(len(a))]}
)


slice_cases = [
Expand Down Expand Up @@ -84,7 +86,7 @@ def test_contains_re_non_strict_raises(ldf):


def test_contains_re_non_literal_raises(ldf):
q = ldf.select(pl.col("a").str.contains(pl.col("b"), literal=False))
q = ldf.select(pl.col("a").str.contains(pl.col("c"), literal=False))

assert_ir_translation_raises(q, NotImplementedError)

Expand Down
Loading