Skip to content

Commit

Permalink
continue fixing up
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon-b-miller committed Aug 4, 2024
1 parent 4f1868b commit d91d59a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 4 additions & 5 deletions python/cudf_polars/cudf_polars/dsl/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,10 @@ def _validate_input(self):
format, strict, exact, cache = self.options
if cache:
raise NotImplementedError("Strptime cache is a CPU feature")
if format is None:
raise NotImplementedError("Strptime format is required")
if not exact:
raise NotImplementedError("Strptime does not support exact=False")

def do_evaluate(
self,
Expand Down Expand Up @@ -836,11 +840,6 @@ def do_evaluate(
format, strict, exact, cache = self.options
col = self.children[0].evaluate(df, context=context, mapping=mapping)

if format is None:
raise NotImplementedError("Strptime requires a format string")

if not exact:
raise NotImplementedError("Strptime does not support exact=False")
not_timestamps = plc.unary.unary_operation(
plc.strings.convert.convert_datetime.is_timestamp(
col.obj, format.encode()
Expand Down
10 changes: 7 additions & 3 deletions python/cudf_polars/tests/expressions/test_stringfunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,17 @@ def to_datetime_data():

@pytest.mark.parametrize("cache", [True, False], ids=lambda cache: f"cache={cache}")
@pytest.mark.parametrize("strict", [True, False], ids=lambda strict: f"strict={strict}")
def test_to_datetime(to_datetime_data, cache, strict):
@pytest.mark.parametrize("exact", [True, False], ids=lambda exact: f"exact={exact}")
@pytest.mark.parametrize(
"format", ["%Y-%m-%d", None], ids=lambda format: f"format={format}"
)
def test_to_datetime(to_datetime_data, cache, strict, format, exact):
query = to_datetime_data.select(
pl.col("a").str.strptime(
pl.Datetime("ns"), format="%Y-%m-%d", cache=cache, strict=strict
pl.Datetime("ns"), format=format, cache=cache, strict=strict, exact=exact
)
)
if cache:
if cache or format is None or not exact:
assert_ir_translation_raises(query, NotImplementedError)
return
else:
Expand Down

0 comments on commit d91d59a

Please sign in to comment.