Skip to content

Bizarre day parsing issue #307

Description

@robertzk

I have a very spooky dataset. It fails to parse in full on this exact set in this exact order, but parses fine in every subset / subsample I have tried.

dates <- c("{ND}", "{ND}", "{ND}", "2006-11-26", "{ND}", "{ND}", "{ND}",
"2010-06-05", "2014-06-01", "{ND}", "{ND}", "{ND}", "{ND}", "{ND}",
"{ND}", "{ND}", "{ND}", "2006-10-31", "{ND}", "{ND}", "{ND}",
"{ND}", "{ND}", "{ND}", "{ND}", "{ND}", "2010-10-31", "2009-05-01",
"{ND}", "{ND}", "{ND}", "{ND}", "{ND}", "{ND}", "{ND}", "{ND}",
"{ND}", "{ND}", "{ND}", NA, "{ND}", "{ND}", "{ND}", "{ND}", "{ND}",
"{ND}", "{ND}", "{ND}", "{ND}", "{ND}", "{ND}", "{ND}", "2008-09-09",
"{ND}", "2003-01-01", "{ND}", "{ND}", "2013-02-28", "2011-10-31",
"{ND}", "{ND}", "{ND}", "{ND}", "{ND}", "{ND}", "{ND}", "{ND}",
"{ND}", "{ND}", "{ND}", "{ND}", "{ND}", "{ND}", "{ND}", "{ND}",
"{ND}", "{ND}", "{ND}", "{ND}", "{ND}", "{ND}", "{ND}", "{ND}",
"{ND}", "{ND}", "{ND}", "{ND}", "2010-08-31", "{ND}", "{ND}",
"2011-02-01", "2012-03-31", "2013-06-04", "{ND}", "{ND}", "{ND}",
"{ND}", "{ND}", "2005-12-12", "2006-09-30", NA, "{ND}")

First, notice

> all(is.na(lubridate::ymd(dates)))
[1] TRUE

However, every other variation of samples I have tried parses fine...

variations <- list(dates[-1], dates[-102], sample(dates), sample(dates, 50), dates[-50], dates[c(F,T)], dates[c(T,T,T,T,F)], dates[102:1])
all(sapply(variations, function(v) !all(is.na(lubridate::ymd(v)))))
# [1] TRUE

Note that shuffling the vector or reversing it is sufficient to get ymd to parse the vector correctly.

I understand if you don't want to look into / fix this, but it did cause a production issue. Baffling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions