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 2021/11/08 22:55:28 UTC

[GitHub] [arrow] jonkeane commented on a change in pull request #11645: ARROW-13888: [R] Rephrase docs for schema()'s ellipses argument and rephrase error message

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



##########
File path: r/R/schema.R
##########
@@ -157,6 +165,9 @@ Schema$create <- function(...) {
   .list <- list2(...)
   if (all(map_lgl(.list, ~ inherits(., "Field")))) {
     schema_(.list)
+  } else if (is.null(names(.list))) {
+    # If not supplied as fields, only other alternative is e.g.`a = int16()`
+    abort("Schema definitions must be supplied as field/data type or field name/data type pairs")
   } else {
     schema_(.fields(.list))
   }

Review comment:
       Would it be possible (and if so wise?) to check if `length(.list) == 1 && schema_check(.list[[1]])` then  schema_(.fields(.list[[1]]))? 
   
   One could always call `do.call(schema, list)`, but it might be nice to also accept a single list containing the specifications too?

##########
File path: r/R/schema.R
##########
@@ -328,3 +339,7 @@ print.arrow_r_metadata <- function(x, ...) {
   utils::str(.unserialize_arrow_r_metadata(x))
   invisible(x)
 }
+
+schema_check <- function(items) {
+  all(map_lgl(.list, ~ inherits(.x, "Field"))) || FALSE
+}

Review comment:
       Is `schema_check` used elsewhere? I don't see it but I might be missing something?




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