You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "nealrichardson (via GitHub)" <gi...@apache.org> on 2023/04/17 16:49:47 UTC

[GitHub] [arrow] nealrichardson commented on a diff in pull request #35172: GH-35035: [R] Implement names<- for Schemas

nealrichardson commented on code in PR #35172:
URL: https://github.com/apache/arrow/pull/35172#discussion_r1169017117


##########
r/tests/testthat/test-schema.R:
##########
@@ -260,3 +260,22 @@ test_that("as_schema() works for StructType objects", {
   struct_type <- struct(col1 = int32())
   expect_equal(as_schema(struct_type), schema(col1 = int32()))
 })
+
+test_that("schema name assignment", {
+  schm <- schema(x = int8(), y = string(), z = double())
+  expect_identical(names(schm), c("x", "y", "z"))
+  names(schm) <- c("a", "b", "c")
+  expect_identical(names(schm), c("a", "b", "c"))
+  expect_error(names(schm) <- "f")
+  expect_error(names(schm) <- letters)
+  expect_error(names(schm) <- character(0))
+  expect_error(names(schm) <- NULL)
+  expect_error(names(schm) <- c(TRUE, FALSE))

Review Comment:
   L269-271 are all the same, right? strings but not the right length, so libarrow will raise.
   
   L272-273 will raise from the cpp11 wrapping since you haven't passed strings. 
   
   So maybe you can reduce this to two tests: one that looks for the "wrong number of args" message, and one that looks for the type mismatch message. Those seem safe enough to make assertions about, and minimizes the risk from asserting about other libraries' error messages.
   
   This is another case that #34826 would help with.



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