jonkeane commented on code in PR #38917:
URL: https://github.com/apache/arrow/pull/38917#discussion_r1518585262
##########
r/tests/testthat/test-schema.R:
##########
@@ -315,5 +315,14 @@ test_that("schema extraction", {
adq <- as_adq(example_data)
expect_equal(schema(adq), adq$.data$schema)
+})
+test_that("schema print truncation", {
+ tbl <- arrow_table(example_data)
+ out <- print_schema_fields(schema(tbl), truncate = TRUE, max_fields = 1)
+ expect_output(
+ cat(out),
+ "int: int32\n...\n6 more columns\nUse `schema()` to see entire schema",
+ fixed = TRUE
+ )
Review Comment:
I assume we already cover the `n_fields < max_fields` case in other tests,
yeah?
What happens if `max_fields` is 0 or negative? We might not need to
specifically catch these in code, since if I'm reading correctly no end user
would ever be able to control that, right? But maybe a comment would be good?
##########
r/R/record-batch-reader.R:
##########
@@ -100,7 +100,11 @@ RecordBatchReader <- R6Class("RecordBatchReader",
read_table = function() Table__from_RecordBatchReader(self),
Close = function() RecordBatchReader__Close(self),
export_to_c = function(stream_ptr) ExportRecordBatchReader(self,
stream_ptr),
- ToString = function() self$schema$ToString(),
+ ToString = function() {
+ n_fields_out <- paste0(length(self$schema$fields), " columns", "\n")
+ schema <- self$schema$ToString(truncate = TRUE)
+ paste0(n_fields_out, schema)
+ },
Review Comment:
There is only one other copy of this, so there's not _a huge amount of
benefit_ but do you want to factor this into a helper function and use it here
+ for `Dataset$ToString()`
--
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]