asfimport opened a new issue, #20486:
URL: https://github.com/apache/arrow/issues/20486

   I am importing a dataset with arrow, and then converting variable types. But 
I got an error message because the `arrow` implementation of `as.integer` can't 
handle empty strings (which is legal in base R). Is this a bug?
   ```r
   
   #In R
   '' %>% as.integer()
   
   [1] NA
   
    
   
   #in arrow
   
   q <- data.table(x=c('','1','2'))
   q %>% write_dataset('q')
   q2 <- 'q' %>% open_dataset %>% mutate(x=as.integer(x)) %>% collect
   
   Error in `collect()`:
   ! Invalid: Failed to parse string: '' as a scalar of type int32
   Run `rlang::last_error()` to see where the error occurred.
   ```
   Update: tryed to preprocess x with `ifelse` but it also did not work.
   ```r
   
   'q' %>% open_dataset %>% mutate(x= ifelse(x=='',NA,x)) %>% 
mutate(x=as.integer(x)) %>% collect
   Error in `collect()`:
   ! NotImplemented: Function 'if_else' has no kernel matching input types 
(bool, bool, string)
   Run `rlang::last_error()` to see where the error occurred.
   ```
   
   **Reporter**: [Lucas 
Mation](https://issues.apache.org/jira/browse/ARROW-18241) / @lucasmation
   #### Related issues:
   - [[R] Possible bug in Handling Blank Conversion to Missing 
Value](https://github.com/apache/arrow/issues/33446) (is duplicated by)
   
   <sub>**Note**: *This issue was originally created as 
[ARROW-18241](https://issues.apache.org/jira/browse/ARROW-18241). Please see 
the [migration documentation](https://github.com/apache/arrow/issues/14542) for 
further details.*</sub>


-- 
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