dask-sql icon indicating copy to clipboard operation
dask-sql copied to clipboard

Check for `np.timedelta64` in `as_timelike`

Open sarahyurick opened this issue 3 years ago • 1 comments

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.

sarahyurick avatar Oct 12 '22 20:10 sarahyurick

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%) :arrow_up:

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

codecov-commenter avatar Oct 12 '22 21:10 codecov-commenter