amoeba commented on code in PR #38917:
URL: https://github.com/apache/arrow/pull/38917#discussion_r1518289303


##########
r/R/schema.R:
##########
@@ -224,9 +224,16 @@ prepare_key_value_metadata <- function(metadata) {
   map_chr(metadata, as.character)
 }
 
-print_schema_fields <- function(s) {
-  # Alternative to Schema__ToString that doesn't print metadata
-  paste(map_chr(s$fields, ~ .$ToString()), collapse = "\n")
+# Alternative to Schema__ToString that doesn't print metadata
+print_schema_fields <- function(s, truncate = FALSE, max_fields = 20) {
+  if (truncate && length(s$fields) > max_fields) {
+    fields_out <- paste(map_chr(s$fields[1:max_fields], ~ .$ToString()), 
collapse = "\n")

Review Comment:
   ```suggestion
       fields_out <- paste(map_chr(s$fields[seq_len(max_fields)], ~ 
.$ToString()), collapse = "\n")
   ```
   
   I don't think this fixes a bug since the line is guarded but I prefer the 
more defensive approach.



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