paleolimbot commented on a change in pull request #12324:
URL: https://github.com/apache/arrow/pull/12324#discussion_r807192866
##########
File path: r/tests/testthat/test-Array.R
##########
@@ -989,6 +989,75 @@ test_that("auto int64 conversion to int can be disabled
(ARROW-10093)", {
})
})
+test_that("concat_arrays works", {
+ concat_empty <- concat_arrays()
+ expect_true(concat_empty$type == null())
+ expect_equal(concat_empty$length(), 0L)
Review comment:
In R, `vctrs::vec_c()` returns `NULL`, which can be inserted into
another `vec_c()` call without affecting the (type or size of the) result. A
`null()` of length 0 works similarly in Arrow (it can be cast to any type).
It's nice when programming (for the same reason that `all(logical(0))` is
`TRUE`).
``` r
library(arrow, warn.conflicts = FALSE)
library(vctrs, warn.conflicts = FALSE)
some_user_input1 <- list()
some_user_input2 <- list()
result_of_some_op <- concat_arrays(!!! some_user_input1, !!!
some_user_input2)
some_user_input <- list(1L, 2:4)
(final_result <- concat_arrays(!!! some_user_input, result_of_some_op, type
= int32()))
#> Array
#> <int32>
#> [
#> 1,
#> 2,
#> 3,
#> 4
#> ]
```
--
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]