roll does not work with nanotime (integer64)

Open
#4,433 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
r
Domain
data

Research direction

Start by reproducing the reported data.table joins using roll with nanotime, bit64/integer64, and POSIXct values. Compare the observed results with the expected rolling matches and verify the behavior for numeric, integer64, and time-based inputs; the issue names no source file or test to begin from.

Written by the indexing model from the issue text.

Description

bit64 non-equi joins

Hello, I found the following bug where using roll and nanotime

library(data.table)
library(nanotime)
library(bit64)

X = data.table(t = c(0, 1))
Y = data.table(t = c(2, 9))

# expected nbehaviour
X[Y, on = .(t), .(x.t, i.t)]
     x.t   i.t
1:  NA   2
2:  NA   9
# roll expected behaviour
X[Y, on = .(t), .(x.t, i.t), roll = 1]
   x.t    i.t
1:   1     2
2:  NA   9

options(nanotimeFormat = "%Y-%m-%dT%H:%M:%E9S")
X = data.table(t = nanotime(c("2020-01-02T16:34:58.393243640", "2020-01-02T16:34:58.393243641")))
Y = data.table(t = nanotime(c("2020-01-02T16:34:58.393243642", "2020-01-02T16:34:58.393243649")))

# usual nonsense for NA but correct
X[Y, on = .(t), .(x.t, i.t)]
                             x.t                           i.t
1: 2262-02-18T20:47:17.227407266 2020-01-02T16:34:58.393243642
2: 2262-02-18T20:47:17.227407266 2020-01-02T16:34:58.393243649

# I think incorrect
>  X[Y, on = .(t), .(x.t, i.t), roll = 1]
                             x.t                           i.t
1: 2020-01-02T16:34:58.393243641 2020-01-02T16:34:58.393243642
2: 2020-01-02T16:34:58.393243641 2020-01-02T16:34:58.393243649

# I think incorrect
>  X[Y, on = .(t), .(x.t, i.t), roll = as.integer64(1)]
                             x.t                           i.t
1: 2020-01-02T16:34:58.393243641 2020-01-02T16:34:58.393243642
2: 2020-01-02T16:34:58.393243641 2020-01-02T16:34:58.393243649

# Same with POSIXct

X = data.table(t = as.POSIXct(c("2020-01-02 16:34:58.390", "2020-01-02 16:34:58.391"))) 
Y = data.table(t = as.POSIXct(c("2020-01-02 16:34:58.392", "2020-01-02 16:34:58.399"))) 
X[Y, on = .(t), .(x.t, i.t), roll = 0.001]                                              
                       x.t                     i.t                                                 
1: 2020-01-02 16:34:58.391 2020-01-02 16:34:58.391                                                 
2:                    <NA> 2020-01-02 16:34:58.398                                                 

Note:
linked to https://stackoverflow.com/questions/58916594/why-does-min200-300-returns-300-for-integer64-class ?
Edit 2020-06-25
probably unlinked

Dominant language
R
Stars
3.9k
Forks
1.1k
Avg merge
14h 4m
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Rdatatable/data.table

All issues in Rdatatable/data.table

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.