You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/03/02 22:56:11 UTC

[GitHub] [arrow] jonkeane commented on a change in pull request #12533: ARROW-15817: [R] Use TableSourceNode instead of InMemoryDataset

jonkeane commented on a change in pull request #12533:
URL: https://github.com/apache/arrow/pull/12533#discussion_r818170225



##########
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:
       If I'm reading the head method correctly, it reads from the RecordBatchReader, but pushes the records back on so that they can be read again if necessary. Should we add a test that confirms this?
   
   Something like:
   ```
   expect_equal(head(reader, 10), Table$create(batch))
   expect_equal(reader$read_table(), Table$create(batch, batch))
   ```




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org