nealrichardson commented on a change in pull request #12533:
URL: https://github.com/apache/arrow/pull/12533#discussion_r818245512
##########
File path: r/tests/testthat/test-record-batch-reader.R
##########
@@ -139,3 +139,21 @@ test_that("reader with 0 batches", {
expect_r6_class(tab, "Table")
expect_identical(dim(tab), c(0L, 1L))
})
+
+test_that("reader head method edge cases", {
+ batch <- record_batch(
+ x = 1:10,
+ y = letters[1:10]
+ )
+ sink <- BufferOutputStream$create()
+ writer <- RecordBatchStreamWriter$create(sink, batch$schema)
+ writer$write(batch)
+ writer$write(batch)
+ writer$close()
+ buf <- sink$finish()
+
+ reader <- RecordBatchStreamReader$create(buf)
+ expect_error(head(reader, -1)) # Not (yet) supported
+ expect_equal(head(reader, 0), Table$create(x = integer(0), y = character(0)))
+ expect_equal(head(reader, 100), Table$create(batch, batch))
Review comment:
Actually I believe the opposite is true: the method is consuming the
reader. RecordBatchReader (and Scanner) are one-shot. (I think you may be
misreading the C++ function: `reader` is the reader and we collect into
`batches` via `push_back`, there is no pushing back into `reader`.)
--
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]