dragosmg commented on PR #13070:
URL: https://github.com/apache/arrow/pull/13070#issuecomment-1137441893

   I've been thinking a bit about this. I wasn't able to find a way to mimic 
the `base::as.Date()` behaviour. I proposed we could keep the existing 
behaviour of **not** allowing more that one format for `tryFormats`. This would 
be consistent with the `strptime` behaviour, where the base R version allows a 
`format` vector longer than 1 and recycles the vector, while Arrow's version of 
`strptime` does not allow a `format` vector longer than 1. 
   
   reprex to show `base::strptime()` with a format vector longer than 1 and the 
accompanying recycling behaviour:
   ``` r
   library(arrow, warn.conflicts = FALSE)
   
   a <- c("2022-01-01", "2022/01/02", "2022/01/03", "2022-01-04", NA)
   strptime(a, format = c("%Y-%m-%d", "%Y/%m/%d"))
   #> [1] "2022-01-01 GMT" "2022-01-02 GMT" NA               NA              
   #> [5] NA
   
   call_function("strptime", Array$create(a), 
                 options = list(format = c("%Y-%m-%d", "%Y/%m/%d"), unit = 0L, 
error_is_null = TRUE))
   #> Error: Expected string vector of length 1
   ```
   
   <sup>Created on 2022-05-25 by the [reprex 
package](https://reprex.tidyverse.org) (v2.0.1)</sup>  
   
   What do you think @jonkeane?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to