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

[R] RecordBatchReaderHead from ExecPlan with UDF cannot be read

    XMLWordPrintableJSON

Details

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

    Description

        register_scalar_function(
          "times_32",
          function(context, x) x * 32.0,
          int32(),
          float64(),
          auto_convert = TRUE
        )
        record_batch(a = 1:1000) %>%
          dplyr::mutate(b = times_32(a)) %>%
          as_record_batch_reader() %>%
          head(11) %>%
          as_arrow_table()
      
      # Error: NotImplemented: Call to R (resolve scalar user-defined function output data type) from a non-R thread from an unsupported context
      # /arrow/cpp/src/arrow/compute/exec.cc:649  kernel_->signature->out_type().Resolve(kernel_ctx_, args.inputs)
      # /arrow/cpp/src/arrow/compute/exec/expression.cc:602  executor->Init(&kernel_context, {kernel, types, options})
      # /arrow/cpp/src/arrow/compute/exec/project_node.cc:91  ExecuteScalarExpression(simplified_expr, target, plan()->exec_context())
      # /arrow/cpp/src/arrow/record_batch.cc:336  ReadNext(&batch)
      # /arrow/cpp/src/arrow/record_batch.cc:350  ToRecordBatches()
      

      It works fine if you don't call as_record_batch_reader() in the middle. Oddly, it also works fine if you add as_adq() (aka collapse()) after head() and before evaluating to table--that is, if you run it through an ExecPlan again, it doesn't error.

      Attachments

        Issue Links

          Activity

            People

              paleolimbot Dewey Dunnington
              npr Neal Richardson
              Votes:
              0 Vote for this issue
              Watchers:
              3 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 - 1h 20m
                  1h 20m