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

[BUG] Support string to datetime conversion in Polars engine #16174

Open
beckernick opened this issue Jul 2, 2024 · 1 comment
Open

[BUG] Support string to datetime conversion in Polars engine #16174

beckernick opened this issue Jul 2, 2024 · 1 comment
Assignees
Labels
cudf.polars Issues specific to cudf.polars feature request New feature or request

Comments

@beckernick
Copy link
Member

beckernick commented Jul 2, 2024

It looks like our string to datetime utilities throws an error. This is a fairly common step while cleaning datasets, so it'd be nice to support it:

import polars as pl
from functools import partial
from cudf_polars.callback import execute_with_cudf
import numpy as np

use_cudf = partial(execute_with_cudf, raise_on_fail=True)

ldf = pl.DataFrame({
    "date": ['2015-09-11', '2017-02-08', '2015-08-01', '2019-03-16', '2015-05-15'],
    "val": [1, 2, 3, 4, 5]
}).lazy()

print(ldf.with_columns(pl.col("date").str.to_datetime()).collect())
print(ldf.with_columns(pl.col("date").str.to_datetime()).collect(post_opt_callback=use_cudf))
shape: (5, 2)
┌─────────────────────┬─────┐
│ dateval │
│ ------ │
│ datetime[μs]        ┆ i64 │
╞═════════════════════╪═════╡
│ 2015-09-11 00:00:001   │
│ 2017-02-08 00:00:002   │
│ 2015-08-01 00:00:003   │
│ 2019-03-16 00:00:004   │
│ 2015-05-15 00:00:005   │
└─────────────────────┴─────┘
---------------------------------------------------------------------------
ComputeError                              Traceback (most recent call last)
Cell In[141], line 14
     12 ldf.sink_parquet("test.parquet")
     13 print(ldf.with_columns(pl.col("date").str.to_datetime()).collect())
---> 14 print(ldf.with_columns(pl.col("date").str.to_datetime()).collect(post_opt_callback=use_cudf))

File [/raid/nicholasb/miniconda3/envs/all_cuda-122_arch-x86_64/lib/python3.11/site-packages/polars/lazyframe/frame.py:1942](http://10.117.23.184:8882/lab/tree/raid/raid/nicholasb/miniconda3/envs/all_cuda-122_arch-x86_64/lib/python3.11/site-packages/polars/lazyframe/frame.py#line=1941), in LazyFrame.collect(self, type_coercion, predicate_pushdown, projection_pushdown, simplify_expression, slice_pushdown, comm_subplan_elim, comm_subexpr_elim, cluster_with_columns, no_optimization, streaming, background, _eager, **_kwargs)
   1939 # Only for testing purposes atm.
   1940 callback = _kwargs.get("post_opt_callback")
-> 1942 return wrap_df(ldf.collect(callback))

ComputeError: 'cuda' conversion failed: NotImplementedError: String function StringFunction.Strptime
@beckernick beckernick added the bug Something isn't working label Jul 2, 2024
@beckernick
Copy link
Member Author

Ah, the MRE does fail. I had a typo. Editing the issue to make it clear.

@beckernick beckernick changed the title [BUG] Polars string to datetime conversion can throw not implemented error [BUG] Support string to datetime conversion in Polars Jul 2, 2024
@beckernick beckernick changed the title [BUG] Support string to datetime conversion in Polars [BUG] Support string to datetime conversion in Polars engine Jul 2, 2024
@lithomas1 lithomas1 added feature request New feature or request cudf.polars Issues specific to cudf.polars and removed bug Something isn't working labels Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cudf.polars Issues specific to cudf.polars feature request New feature or request
Projects
Status: In Progress
Development

No branches or pull requests

3 participants