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


##########
cpp/src/arrow/compute/exec/plan_test.cc:
##########
@@ -344,6 +344,47 @@ void TestSourceSink(
               
Finishes(ResultWith(UnorderedElementsAreArray(exp_batches.batches))));
 }
 
+void TestRecordBatchReaderSourceSink(
+    std::function<Result<std::shared_ptr<RecordBatchReader>>(const 
BatchesWithSchema&)>
+        to_reader) {
+  ASSERT_OK_AND_ASSIGN(auto executor, arrow::internal::ThreadPool::Make(1));
+  ExecContext exec_context(default_memory_pool(), executor.get());
+  ASSERT_OK_AND_ASSIGN(auto plan, ExecPlan::Make(exec_context));
+  AsyncGenerator<std::optional<ExecBatch>> sink_gen;
+
+  auto exp_batches = MakeBasicBatches();
+  ASSERT_OK_AND_ASSIGN(std::shared_ptr<RecordBatchReader> reader, 
to_reader(exp_batches));
+
+  ASSERT_OK(Declaration::Sequence(
+                {
+                    {"record_batch_reader_source",
+                     RecordBatchReaderSourceNodeOptions{exp_batches.schema, 
reader}},
+                    {"sink", SinkNodeOptions{&sink_gen}},
+                })
+                .AddToPlan(plan.get()));
+
+  ASSERT_THAT(StartAndCollect(plan.get(), sink_gen),
+              
Finishes(ResultWith(UnorderedElementsAreArray(exp_batches.batches))));

Review Comment:
   I don't mind if you fix the other tests in a separate PR.  However, any 
newly added tests should follow the new format.  `TEST(ExecPlanExecution, 
SourceGroupedSum)` is a good example from this file that you can follow.  This 
test, for example, would become something like:
   
   ```
     auto exp_batches = MakeBasicBatches();
     ASSERT_OK_AND_ASSIGN(std::shared_ptr<RecordBatchReader> reader, 
to_reader(exp_batches));
     Declaration plan("record_batch_reader_source", 
RecordBatchReaderSourceNodeOptions{exp_batches.schema, reader});
     ASSERT_OK_AND_ASSIGN(auto out_batches, 
DeclarationToExecBatches(std::move(plan)));
     AssertExecBatchesEqualIgnoringOrder(exp_batches.schema, 
exp_batches.batches, out_batches);
   ```



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