paleolimbot commented on code in PR #13397:
URL: https://github.com/apache/arrow/pull/13397#discussion_r915186870


##########
r/src/compute-exec.cpp:
##########
@@ -109,9 +109,50 @@ std::shared_ptr<arrow::RecordBatchReader> ExecPlan_run(
     auto kv = strings_to_kvm(metadata);
     out_schema = out_schema->WithMetadata(kv);
   }
-  return compute::MakeGeneratorReader(
+
+  std::pair<std::shared_ptr<compute::ExecPlan>, 
std::shared_ptr<arrow::RecordBatchReader>>
+      out;
+  out.first = plan;
+  out.second = compute::MakeGeneratorReader(
       out_schema, [stop_producing, plan, sink_gen] { return sink_gen(); },
       gc_memory_pool());
+  return out;
+}
+
+// [[arrow::export]]
+std::shared_ptr<arrow::RecordBatchReader> ExecPlan_run(

Review Comment:
   It will error with a rather hideous error message whenever the first batch 
is pulled from the reader:
   
   ```
   #> Error: NotImplemented: Call to R from a non-R thread without calling 
RunWithCapturedR
   #> 
/Users/deweydunnington/Desktop/rscratch/arrow/cpp/src/arrow/compute/kernel.cc:391
  resolver_(ctx, args)
   #> 
/Users/deweydunnington/Desktop/rscratch/arrow/cpp/src/arrow/compute/exec.cc:696 
 kernel_->signature->out_type().Resolve(kernel_ctx_, args.inputs)
   #> 
/Users/deweydunnington/Desktop/rscratch/arrow/cpp/src/arrow/compute/exec/expression.cc:602
  executor->Init(&kernel_context, {kernel, descrs, options})
   #> 
/Users/deweydunnington/Desktop/rscratch/arrow/cpp/src/arrow/compute/exec/project_node.cc:92
  ExecuteScalarExpression(simplified_expr, target, plan()->exec_context())
   #> 
/Users/deweydunnington/Desktop/rscratch/arrow/cpp/src/arrow/dataset/scanner.cc:79
  delegate_.Next()
   #> 
/Users/deweydunnington/Desktop/rscratch/arrow/cpp/src/arrow/c/bridge.cc:1651  
reader()->ReadNext(&batch)
   ```
   
   I think I can make that error message better with some changes to the 
call-into-R code.



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