paleolimbot commented on a change in pull request #12324:
URL: https://github.com/apache/arrow/pull/12324#discussion_r806791553
##########
File path: r/tests/testthat/test-Array.R
##########
@@ -989,6 +989,59 @@ 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)
+
+ concat_empty_typed <- concat_arrays(type = int64())
+ expect_true(concat_empty_typed$type == int64())
+ expect_equal(concat_empty$length(), 0L)
+
+ concat_int <- concat_arrays(Array$create(1:3), Array$create(4:5))
+ expect_true(concat_int$type == int32())
+ expect_true(all(concat_int == Array$create(1:5)))
+
+ concat_int64 <- concat_arrays(
+ Array$create(1:3),
+ Array$create(4:5, type = int64()),
+ type = int64()
+ )
+ expect_true(concat_int64$type == int64())
+ expect_true(all(concat_int == Array$create(1:5)))
+
+ expect_error(
+ concat_arrays(
+ Array$create(1:3),
+ Array$create(4:5, type = int64())
+ ),
+ "must be identically typed"
+ )
+})
+
+test_that("c() works for Array", {
Review comment:
Good call! This is another example of the madness around `c()` (which we
can do little about except circumvent it by eventually defining a vctrs
implementation).
``` r
library(arrow, warn.conflicts = FALSE)
c(Array$create(1L), 2L)
#> Array
#> <int32>
#> [
#> 1,
#> 2
#> ]
c(2L, Array$create(1L))
#> [[1]]
#> [1] 2
#>
#> [[2]]
#> Array
#> <int32>
#> [
#> 1
#> ]
```
<sup>Created on 2022-02-15 by the [reprex
package](https://reprex.tidyverse.org) (v2.0.1)</sup>
--
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]