Frank Smith created ARROW-10337:
-----------------------------------

             Summary: More liberal parsing of ISO8601 timestamps with 
fractional seconds
                 Key: ARROW-10337
                 URL: https://issues.apache.org/jira/browse/ARROW-10337
             Project: Apache Arrow
          Issue Type: Improvement
          Components: C++
            Reporter: Frank Smith
            Assignee: Frank Smith


The current ISO8601 timestamp parser assumes MILLI timestamps have 3 decimal 
places, MICRO have 6 and NANO have 9. From ParseTimestampISO8601 in 
cpp/src/arrow/util/value_parsing.h:

{{ // We allow the following formats for all units:}}
{{ // - "YYYY-MM-DD"}}
{{ // - "YYYY-MM-DD[ T]hh"}}
{{ // - "YYYY-MM-DD[ T]hhZ"}}
{{ // - "YYYY-MM-DD[ T]hh:mm"}}
{{ // - "YYYY-MM-DD[ T]hh:mmZ"}}
{{ // - "YYYY-MM-DD[ T]hh:mm:ss"}}
{{ // - "YYYY-MM-DD[ T]hh:mm:ssZ"}}
{{ //}}
{{ // We allow the following formats for unit==MILLI:}}
{{ // - "YYYY-MM-DD[ T]hh:mm:ss.mmm"}}
{{ // - "YYYY-MM-DD[ T]hh:mm:ss.mmmZ"}}
{{ //}}
{{ // We allow the following formats for unit==MICRO:}}
{{ // - "YYYY-MM-DD[ T]hh:mm:ss.uuuuuu"}}
{{ // - "YYYY-MM-DD[ T]hh:mm:ss.uuuuuuZ"}}
{{ //}}
{{ // We allow the following formats for unit==NANO:}}
{{ // - "YYYY-MM-DD[ T]hh:mm:ss.nnnnnnnnn"}}
{{ // - "YYYY-MM-DD[ T]hh:mm:ss.nnnnnnnnnZ"}}
{{ //}}

I propose that we change the parser to accept 1 to 3 digits for MILLI, 1 to 6 
digits for MICRO, and 1 to 9 digits for NANO, as follows:

{{ // We allow the following formats for all units:}}
{{ // - "YYYY-MM-DD"}}
{{ // - "YYYY-MM-DD[ T]hhZ?"}}
{{ // - "YYYY-MM-DD[ T]hh:mmZ?"}}
{{ // - "YYYY-MM-DD[ T]hh:mm:ssZ?"}}
{{ //}}
{{ // We allow the following formats for unit == MILLI, MICRO, or NANO:}}
{{ // - "YYYY-MM-DD[ T]hh:mm:ss.s\{1,3}Z?"}}
{{ //}}
{{ // We allow the following formats for unit == MICRO, or NANO:}}
{{ // - "YYYY-MM-DD[ T]hh:mm:ss.s\{4,6}Z?"}}
{{ //}}
{{ // We allow the following formats for unit == NANO:}}
{{ // - "YYYY-MM-DD[ T]hh:mm:ss.s\{7,9}Z?"}}

This will allow for parsing of timestamps when e.g. a CSV file does not write 
timestamps with trailing zeroes.

I am almost complete implementing this functionality, so a PR will be following 
soon.

 

 
  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to