Skip to content

fcoalesce doesnt play nice w/ date and idate #7545

@ethanbsmith

Description

@ethanbsmith

data.table loads dates as IDate. not an issue, as these can be simply converted to native Date with :=(as.Date())
problem is that the mode on these converted dates is still integer and this causes fcoalesce to puke

very annoying to have to micromanage this all over the place when mixing data sourced both from and not from fread
sort of feels like a self-own. Any way this could be made less cumbersome? maybe fcase special casing Date subclass comparisons?

data.table::fcoalesce(Sys.Date(), as.IDate("9999-12-31")) 
#Error in data.table::fcoalesce(Sys.Date(), as.IDate("9999-12-31")) :    Item 2 is type integer but the first item is type double. Please coerce before coalescing.  
data.table::fcoalesce(Sys.Date(), as.Date(as.IDate("9999-12-31"))) 
#Error in data.table::fcoalesce(Sys.Date(), as.Date(as.IDate("9999-12-31"))) :    Item 2 is type integer but the first item is type double. Please coerce before coalescing.  
data.table::fcoalesce(Sys.Date(), as.Date(as.numeric(as.IDate("9999-12-31")))) 
#[1] "2025-12-29"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions