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

ability to cast python timedelta to Duration #2991

Closed
universalmind303 opened this issue Oct 3, 2024 · 1 comment · Fixed by #3011
Closed

ability to cast python timedelta to Duration #2991

universalmind303 opened this issue Oct 3, 2024 · 1 comment · Fixed by #3011

Comments

@universalmind303
Copy link
Contributor

Is your feature request related to a problem? Please describe.

I want to be able to cast a timedelta to a duration the same way we implicitly convert it if using from_pydict

import daft
import datetime

df = daft.from_pydict(
    {
        "time_delta": [datetime.timedelta(days=1), datetime.timedelta(days=2)],
    }
)
df.collect()

╭────────────────────────╮
│ time_delta             │
│ ---                    │
│ Duration[Microseconds] │
╞════════════════════════╡
│ 86400000000            │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ 172800000000           │
╰────────────────────────╯
(Showing first 2 of 2 rows)

Describe the solution you'd like

df.select(daft.lit(datetime.timedelta(days=1)).cast(daft.DataType.duration('us')))

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@colin-ho
Copy link
Contributor

colin-ho commented Oct 7, 2024

Closed with #3011

@colin-ho colin-ho closed this as completed Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants