jonkeane commented on a change in pull request #8579: URL: https://github.com/apache/arrow/pull/8579#discussion_r518776855
########## File path: r/tests/testthat/test-Table.R ########## @@ -179,10 +183,34 @@ test_that("[[<- assignment", { # can use $ tab$new <- NULL expect_null(as.vector(tab$new)) - expect_identical(dim(tab), c(10L, 5L)) + expect_identical(dim(tab), c(10L, 4L)) tab$int <- 1:10 expect_vector(tab$int, 1:10) + + # recycling + tab[["atom"]] <- 1L + expect_vector(tab[["atom"]], rep(1L, 10)) + + expect_error( + tab[["atom"]] <- 1:6, + paste0( + "Invalid: Added column's length must match table's length. ", + "Expected length 10 but got length 6" + ) + ) + + # assign Arrow array and chunked_array + array <- Array$create(c(10:1)) + tab$array <- array + expect_vector(tab$array, 10:1) + + tab$chunked <- chunked_array(1:10) + expect_vector(tab$chunked, 1:10) + + # nonsense indexes + expect_error(tab[[NA]] <- letters[10:1], "missing value where TRUE/FALSE needed") + expect_error(tab[[NULL]] <- letters[10:1], "argument is of length zero") Review comment: Yeah, I added error checking into the method call for `[[<-` to match the behavior + catch `NA_integer_`. It looks like the NA checking is actually coming from cpp `arrow::r::Input<R_xlen_t>::type`, if I'm reading correctly. I put a TODO note to see about unifying / centralizing that checking ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org