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


##########
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")
+    fields_out <- paste0(fields_out, "\n...\n")

Review Comment:
   Do we know how many fields we're not showing here? Rather than `...`, giving 
a count of hidden fields would be a nice improvement. I'm thinking about how 
pillar does it:
   
   ```
   > starwars
   # A tibble: 87 × 14
      name          height  mass hair_color skin_color eye_color birth_year sex 
  gender homeworld species films vehicles
      <chr>          <int> <dbl> <chr>      <chr>      <chr>          <dbl> 
<chr> <chr>  <chr>     <chr>   <lis> <list>  
    1 Luke Skywalk…    172    77 blond      fair       blue            19   
male  mascu… Tatooine  Human   <chr> <chr>   
    2 C-3PO            167    75 NA         gold       yellow         112   
none  mascu… Tatooine  Droid   <chr> <chr>   
    3 R2-D2             96    32 NA         white, bl… red             33   
none  mascu… Naboo     Droid   <chr> <chr>   
    4 Darth Vader      202   136 none       white      yellow          41.9 
male  mascu… Tatooine  Human   <chr> <chr>   
    5 Leia Organa      150    49 brown      light      brown           19   
fema… femin… Alderaan  Human   <chr> <chr>   
    6 Owen Lars        178   120 brown, gr… light      blue            52   
male  mascu… Tatooine  Human   <chr> <chr>   
    7 Beru Whitesu…    165    75 brown      light      blue            47   
fema… femin… Tatooine  Human   <chr> <chr>   
    8 R5-D4             97    32 NA         white, red red             NA   
none  mascu… Tatooine  Droid   <chr> <chr>   
    9 Biggs Darkli…    183    84 black      light      brown           24   
male  mascu… Tatooine  Human   <chr> <chr>   
   10 Obi-Wan Keno…    182    77 auburn, w… fair       blue-gray       57   
male  mascu… Stewjon   Human   <chr> <chr>   
   # ℹ 77 more rows
   # ℹ 1 more variable: starships <list>
   # ℹ Use `print(n = ...)` to see more rows
   ```



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