You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2018/11/15 18:31:17 UTC
[arrow] branch master updated: ARROW-3784: [R] Array with type
fails with x is not a vector
This is an automated email from the ASF dual-hosted git repository.
wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new cc5b445 ARROW-3784: [R] Array with type fails with x is not a vector
cc5b445 is described below
commit cc5b44563002474ffa69c2fb7db7d0b3564e10b1
Author: Romain Francois <ro...@purrple.cat>
AuthorDate: Thu Nov 15 13:31:09 2018 -0500
ARROW-3784: [R] Array with type fails with x is not a vector
closes #2956 using a better approach. This reserves the `type` argument for when we'll really use it.
```r
> library(arrow)
> array(1:10, type = int16())
arrow::Array
[
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
]
Warning message:
The `type` argument is currently ignored
```
Author: Romain Francois <ro...@purrple.cat>
Closes #2960 from romainfrancois/ARROW-3784/array-type-arg and squashes the following commits:
10a763232 <Romain Francois> "document" the type argument
92d57a8e4 <Romain Francois> reserve the `type` argument, but just warn about it for now.
---
r/NAMESPACE | 2 ++
r/R/ChunkedArray.R | 9 +++++++--
r/R/array.R | 7 ++++++-
r/man/array.Rd | 4 +++-
r/man/chunked_array.Rd | 4 +++-
r/tests/testthat/test-Array.R | 6 ++++++
r/tests/testthat/test-chunkedarray.R | 6 ++++++
7 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/r/NAMESPACE b/r/NAMESPACE
index 46d40e1..93df8ff 100644
--- a/r/NAMESPACE
+++ b/r/NAMESPACE
@@ -148,6 +148,8 @@ importFrom(purrr,map)
importFrom(purrr,map2)
importFrom(purrr,map_int)
importFrom(rlang,dots_n)
+importFrom(rlang,list2)
+importFrom(rlang,warn)
importFrom(tibble,as_tibble)
importFrom(withr,defer_parent)
useDynLib(arrow, .registration = TRUE)
diff --git a/r/R/ChunkedArray.R b/r/R/ChunkedArray.R
index 69c98ba..c681fc3 100644
--- a/r/R/ChunkedArray.R
+++ b/r/R/ChunkedArray.R
@@ -39,8 +39,13 @@
#' create an arrow::Array from an R vector
#'
#' @param \dots Vectors to coerce
+#' @param type currently ignored
#'
+#' @importFrom rlang list2
#' @export
-chunked_array <- function(...){
- shared_ptr(`arrow::ChunkedArray`, ChunkedArray__from_list(rlang::list2(...)))
+chunked_array <- function(..., type){
+ if (!missing(type)) {
+ warn("The `type` argument is currently ignored")
+ }
+ shared_ptr(`arrow::ChunkedArray`, ChunkedArray__from_list(list2(...)))
}
diff --git a/r/R/array.R b/r/R/array.R
index 869479b..bd949dc 100644
--- a/r/R/array.R
+++ b/r/R/array.R
@@ -63,9 +63,14 @@
#' create an arrow::Array from an R vector
#'
#' @param \dots Vectors to coerce
+#' @param type currently ignored
#'
+#' @importFrom rlang warn
#' @export
-array <- function(...){
+array <- function(..., type){
+ if (!missing(type)) {
+ warn("The `type` argument is currently ignored")
+ }
`arrow::Array`$dispatch(Array__from_vector(vctrs::vec_c(...)))
}
diff --git a/r/man/array.Rd b/r/man/array.Rd
index ed81d0c..38bd773 100644
--- a/r/man/array.Rd
+++ b/r/man/array.Rd
@@ -4,10 +4,12 @@
\alias{array}
\title{create an arrow::Array from an R vector}
\usage{
-array(...)
+array(..., type)
}
\arguments{
\item{\dots}{Vectors to coerce}
+
+\item{type}{currently ignored}
}
\description{
create an arrow::Array from an R vector
diff --git a/r/man/chunked_array.Rd b/r/man/chunked_array.Rd
index 27b91cf..1f4fb83 100644
--- a/r/man/chunked_array.Rd
+++ b/r/man/chunked_array.Rd
@@ -4,10 +4,12 @@
\alias{chunked_array}
\title{create an arrow::Array from an R vector}
\usage{
-chunked_array(...)
+chunked_array(..., type)
}
\arguments{
\item{\dots}{Vectors to coerce}
+
+\item{type}{currently ignored}
}
\description{
create an arrow::Array from an R vector
diff --git a/r/tests/testthat/test-Array.R b/r/tests/testthat/test-Array.R
index d06f88f..a3e5134 100644
--- a/r/tests/testthat/test-Array.R
+++ b/r/tests/testthat/test-Array.R
@@ -280,3 +280,9 @@ test_that("support for NaN (ARROW-3615)", {
expect_true(y$IsValid(2))
expect_equal(y$null_count(), 1L)
})
+
+test_that("array ignores the type argument (ARROW-3784)", {
+ a <- expect_warning(array(1:10, type = int16()))
+ b <- array(1:10)
+ expect_equal(a, b)
+})
diff --git a/r/tests/testthat/test-chunkedarray.R b/r/tests/testthat/test-chunkedarray.R
index 088367a..fb45c99 100644
--- a/r/tests/testthat/test-chunkedarray.R
+++ b/r/tests/testthat/test-chunkedarray.R
@@ -159,3 +159,9 @@ test_that("ChunkedArray supports difftime", {
expect_equal(a$length(), 2L)
expect_equal(a$as_vector(), c(time, time))
})
+
+test_that("chunked_array ignores the type argument (ARROW-3784)", {
+ a <- expect_warning(chunked_array(1:10, type = int16()))
+ b <- chunked_array(1:10)
+ expect_equal(a, b)
+})