westonpace commented on code in PR #15183:
URL: https://github.com/apache/arrow/pull/15183#discussion_r1067552121


##########
cpp/examples/arrow/execution_plan_documentation_examples.cc:
##########
@@ -761,6 +759,30 @@ arrow::Status TableSinkExample() {
   std::cout << "Results : " << output_table->ToString() << std::endl;
   return arrow::Status::OK();
 }
+
+// (Doc section: Table Sink Example)
+

Review Comment:
   ```suggestion
   ```



##########
cpp/src/arrow/compute/exec/test_util.cc:
##########
@@ -290,6 +290,18 @@ Result<std::vector<std::shared_ptr<RecordBatch>>> 
ToRecordBatches(
   return record_batches;
 }
 
+Result<std::shared_ptr<RecordBatchReader>> ToRecordBatchReader(
+    const BatchesWithSchema& batches_with_schema) {
+  std::vector<std::shared_ptr<RecordBatch>> record_batches;
+  for (auto batch : batches_with_schema.batches) {
+    ARROW_ASSIGN_OR_RAISE(auto record_batch,
+                          batch.ToRecordBatch(batches_with_schema.schema));
+    record_batches.push_back(record_batch);

Review Comment:
   ```suggestion
       record_batches.push_back(std::move(record_batch));
   ```



##########
cpp/examples/arrow/execution_plan_documentation_examples.cc:
##########
@@ -761,6 +759,30 @@ arrow::Status TableSinkExample() {
   std::cout << "Results : " << output_table->ToString() << std::endl;
   return arrow::Status::OK();
 }
+
+// (Doc section: Table Sink Example)
+
+// (Doc section: RecordBatchReaderSource Example)
+
+/// \brief An example showing the usage of a RecordBatchReader as the data 
source.
+///
+/// RecordBatchReaderSourceSink Example
+/// This example shows how a record_batch_reader_source can be used
+/// in an execution plan. This includes the source node
+/// receiving data from a TableRecordBatchReader.
+
+arrow::Status RecordBatchReaderSourceSinkExample() {
+  ARROW_ASSIGN_OR_RAISE(std::shared_ptr<cp::ExecPlan> plan,
+                        cp::ExecPlan::Make(*cp::threaded_exec_context()));
+

Review Comment:
   ```suggestion
   ```



##########
cpp/src/arrow/compute/exec/plan_test.cc:
##########
@@ -344,6 +344,40 @@ void TestSourceSink(
               
Finishes(ResultWith(UnorderedElementsAreArray(exp_batches.batches))));
 }
 
+void TestRecordBatchReaderSourceSink(
+    std::function<Result<std::shared_ptr<RecordBatchReader>>(const 
BatchesWithSchema&)>
+        to_reader) {
+  for (bool parallel : {false, true}) {
+    SCOPED_TRACE(parallel ? "parallel/merged" : "serial");
+    auto exp_batches = MakeBasicBatches();
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<RecordBatchReader> reader,
+                         to_reader(exp_batches));
+    RecordBatchReaderSourceNodeOptions options{reader};
+    Declaration plan("record_batch_reader_source", std::move(options));
+    ASSERT_OK_AND_ASSIGN(auto result, DeclarationToExecBatches(plan, 
parallel));
+    AssertExecBatchesEqualIgnoringOrder(result.schema, result.batches,
+                                        exp_batches.batches);
+  }
+}
+
+void TestRecordBatchReaderSourceSinkError(
+    std::function<Result<std::shared_ptr<RecordBatchReader>>(const 
BatchesWithSchema&)>
+        to_reader) {
+  ASSERT_OK_AND_ASSIGN(auto plan, ExecPlan::Make());
+  std::shared_ptr<Schema> no_schema;

Review Comment:
   ```suggestion
   ```



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