Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-15659

[R] strptime should return NA (not error) with format mismatch

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 8.0.0
    • R

    Description

      base::strptime() returns NA when the value passed to the format argument does not match the string to be parsed. The arrow binding currently errors in the same scenario.

      strptime("2022-02-11", format = "%Y-%m-%d")
      #> [1] "2022-02-11 GMT"
      strptime("2022-02-11", format = "%Y %m-%d")
      #> [1] NA
      
      suppressMessages(library(lubridate))
      suppressMessages(library(arrow))
      suppressMessages(library(dplyr))
      
      df <- tibble(x = "2022-02-11")
      
      df %>% 
        mutate(z = strptime(x, format = "%Y-%m %d"))
      #> # A tibble: 1 × 2
      #>   x          z     
      #>   <chr>      <dttm>
      #> 1 2022-02-11 NA
      
      df %>% 
        record_batch() %>% 
        mutate(z = strptime(x, format = "%Y-%m %d")) %>% 
        collect()
      #> Error: Invalid: Failed to parse string: '2022-02-11' as a scalar of type timestamp[ms]
      

      Attachments

        Issue Links

          Activity

            People

              dragosmg Dragoș Moldovan-Grünfeld
              dragosmg Dragoș Moldovan-Grünfeld
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 6h 10m
                  6h 10m