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

[C++] Add cast option to return null for values that can't convert

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • C++, R
    • None

    Description

      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?

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

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

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              lucasmation Lucas Mation
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: