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

[R] %in% on an empty vector c() fails

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 9.0.0
    • 10.0.0
    • R

    Description

      When using %in% on empty vectors I'm getting an error

      "Error: Cannot infer type from vector"

      I'd expect this to work the same as base R where you can use %in% on empty vectors.

      The arrow::is_in compute function does accept nulls as the value_set. If I manually create an empty array of type NULL it does work as expected.

      Reprex:

      library(dplyr)
      library(arrow)
      
      options(arrow.debug=T)
      
      #base R
      a <- c(1,2,3)
      b <- c() # NULL
      a %in% b
      #> [1] FALSE FALSE FALSE
      
      # arrow arrays
      arrowArray <- arrow::Array$create(c(1,2,3))
      arrow::is_in(arrowArray, c())
      #> Error: Cannot infer type from vector
      
      # define type of c() manually
      arrow::is_in(arrowArray, arrow::Array$create(c(), type=arrow::null()))
      #> Array
      #> <bool>
      #> [
      #>   false,
      #>   false,
      #>   false
      #> ]
      

      Attachments

        Issue Links

          Activity

            People

              egillax Egill Axfjord Fridgeirsson
              egillax Egill Axfjord Fridgeirsson
              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 - 50m
                  50m