icexelloss commented on code in PR #35953:
URL: https://github.com/apache/arrow/pull/35953#discussion_r1235766359


##########
cpp/src/arrow/acero/plan_test.cc:
##########
@@ -767,6 +767,24 @@ TEST(ExecPlanExecution, DeclarationToReader) {
                                   reader->Next());
 }
 
+TEST(ExecPlanExecution, DeclarationToReaderWithEarlyClose) {
+  auto random_data = MakeRandomBatches(schema({field("a", int8())}), 
/*num_batches=*/100);
+  auto plan = Declaration::Sequence(
+      {{"source", SourceNodeOptions(random_data.schema, random_data.gen(false, 
false))}});
+  ASSERT_OK_AND_ASSIGN(std::unique_ptr<RecordBatchReader> reader,
+                       DeclarationToReader(plan, /*use_threads=*/false));
+
+  // read only a few batches
+  for (size_t i = 0; i < 10; i++) {
+    ASSERT_OK(reader->Next());
+  }
+  // then close
+  EXPECT_RAISES_WITH_MESSAGE_THAT(Cancelled, HasSubstr("Plan was cancelled 
early"),
+                                  reader->Close());

Review Comment:
   If the expectation of "close" here is to "cancel the query gracefully", then 
I think the reasonable behaviors should be returning status OK if the 
cancellation is successful. I don't think raises an exception "Plan is 
cancelled" is the correct behavior then the user actually wanted to "cancel the 
plan".
   
   



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