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

Check for np.timedelta64 in as_timelike #860

Merged
merged 3 commits into from
Oct 18, 2022

Conversation

sarahyurick
Copy link
Collaborator

When I try:

from dask_sql import Context
import pandas as pd
import dask.dataframe as dd
from datetime import datetime

c = Context()

date = datetime(2021, 10, 3, 15, 53, 42, 47)
date2 = datetime(2021, 2, 3, 15, 53, 42, 47)

df = dd.from_pandas(pd.DataFrame({"d": [date, date2]}), npartitions=1)
c.register_dask_table(df, "df")

c.sql(
"""
SELECT d + INTERVAL '5 days' FROM df
"""
)

It fails with a Don't know how to make <class 'numpy.timedelta64'> timelike. This is because we are adding 5 days (432000000 milliseconds) but not checking if it's a np.timedelta64 type (in which case, it's already in the desired format and can be returned as is). This small PR fixes the bug.

@codecov-commenter
Copy link

codecov-commenter commented Oct 12, 2022

Codecov Report

Merging #860 (072b5a0) into main (82960ca) will increase coverage by 0.13%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #860      +/-   ##
==========================================
+ Coverage   77.44%   77.58%   +0.13%     
==========================================
  Files          71       71              
  Lines        3600     3600              
  Branches      634      634              
==========================================
+ Hits         2788     2793       +5     
+ Misses        685      676       -9     
- Partials      127      131       +4     
Impacted Files Coverage Δ
dask_sql/physical/rex/core/call.py 81.03% <0.00%> (ø)
dask_sql/_version.py 34.00% <0.00%> (+1.44%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Collaborator

@charlesbluca charlesbluca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix @sarahyurick 😄 could we add a test for this case?

@charlesbluca charlesbluca merged commit f9fbf5e into dask-contrib:main Oct 18, 2022
@sarahyurick sarahyurick deleted the as_timelike branch May 26, 2023 22:16
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 this pull request may close these issues.

4 participants