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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]