Skip to content

Merge (outer join) fails to set NAs for integer64 #1385

@dlithio

Description

@dlithio

Related to #488.

require(data.table)
require(bit64)
dt1 <- data.table(x = c(1),y = integer64(1))
dt2 <- data.table(x = c(1,2))
setkey(dt1,x)
setkey(dt2,x)
merge(dt1,dt2,all=TRUE)
#   x                   y
#1: 1                   0
#2: 2 9218868437227407266

can reach the desired result by the workaround

dt <- merge(dt1,dt2,all=TRUE)
dt[as.character(y)== "9218868437227407266", y := as.integer64(NA)]
dt
#   x  y
#1: 1  0
#2: 2 NA

there is a note about what may be causing this behavior in the bit64 reference

Subscripting non-existing elements and subscripting with NAs is currently not supported. Such subscripting currently returns 9218868437227407266 instead of NA (the NA value of the underlying double code). Following the full R behaviour here would either destroy performance or require extensive C-coding.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions