Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARROW-4560: [R] array() needs to take single input, not ... #3635

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
762e000
array() no longer take ...
romainfrancois Feb 13, 2019
86157bc
prepare to handle the type argument in `array()`
romainfrancois Feb 13, 2019
db05f36
+ type() function to get or infer the arrow type
romainfrancois Feb 14, 2019
26d1a95
converter/builder api for int types and boolean
romainfrancois Feb 18, 2019
5c9371d
handling array(type = float64())
romainfrancois Feb 18, 2019
2d31e2d
handling array(type = float32())
romainfrancois Feb 18, 2019
37b63ec
array(type = date32())
romainfrancois Feb 18, 2019
92c0819
array(type = date64())
romainfrancois Feb 18, 2019
712c22e
array(type = timestamp())
romainfrancois Feb 18, 2019
803570a
array(type = timestamp())
romainfrancois Feb 19, 2019
0707f67
array(type = time32|64() )
romainfrancois Feb 19, 2019
6d16fb6
infer internally so that we know if we have infered, we need that for…
romainfrancois Feb 19, 2019
e23aabf
cleanup
romainfrancois Feb 19, 2019
915d352
better format the error message
romainfrancois Feb 19, 2019
fd76173
more tests about array(type = )
romainfrancois Feb 19, 2019
25d0ac6
no longer need remote vctrs because no longer use vec_c() internally …
romainfrancois Feb 19, 2019
2bffd69
relax factors
romainfrancois Feb 19, 2019
541d069
Simplify GetResult
romainfrancois Feb 19, 2019
ed0b973
implement ChunkedArray__from_list with single type inference so that …
romainfrancois Feb 19, 2019
9804fee
tests for chunked_Array(type =)
romainfrancois Feb 20, 2019
08b2953
R package compatible with arrow 0.12
romainfrancois Feb 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions r/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ Imports:
assertthat,
glue,
R6,
vctrs (>= 0.1.0.9000),
vctrs (>= 0.1.0),
fs,
tibble,
crayon,
withr,
bit64
Remotes:
r-lib/vctrs,
r-lib/withr
Roxygen: list(markdown = TRUE)
RoxygenNote: 6.1.1
Expand Down
6 changes: 6 additions & 0 deletions r/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ S3method(read_table,"arrow::ipc::RecordBatchStreamReader")
S3method(read_table,character)
S3method(read_table,fs_path)
S3method(read_table,raw)
S3method(type,"arrow::Array")
S3method(type,"arrow::ChunkedArray")
S3method(type,"arrow::Column")
S3method(type,default)
S3method(write_arrow,"arrow::ipc::RecordBatchWriter")
S3method(write_arrow,character)
S3method(write_arrow,fs_path)
Expand Down Expand Up @@ -148,6 +152,7 @@ export(table)
export(time32)
export(time64)
export(timestamp)
export(type)
export(uint16)
export(uint32)
export(uint64)
Expand All @@ -165,6 +170,7 @@ importFrom(glue,glue)
importFrom(purrr,map)
importFrom(purrr,map2)
importFrom(purrr,map_int)
importFrom(rlang,"%||%")
importFrom(rlang,abort)
importFrom(rlang,dots_n)
importFrom(rlang,list2)
Expand Down
2 changes: 1 addition & 1 deletion r/R/ArrayData.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#' @section Usage:
#'
#' ```
#' data <- array(...)$data()
#' data <- array(x)$data()
#'
#' data$type()
#' data$length()
Expand Down
9 changes: 3 additions & 6 deletions r/R/ChunkedArray.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,8 @@
#' @param \dots Vectors to coerce
#' @param type currently ignored
#'
#' @importFrom rlang list2
#' @importFrom rlang list2 %||%
#' @export
chunked_array <- function(..., type){
if (!missing(type)) {
warn("The `type` argument is currently ignored")
}
shared_ptr(`arrow::ChunkedArray`, ChunkedArray__from_list(list2(...)))
chunked_array <- function(..., type = NULL){
shared_ptr(`arrow::ChunkedArray`, ChunkedArray__from_list(list2(...), type))
}
25 changes: 25 additions & 0 deletions r/R/R6.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,31 @@ unique_ptr <- function(class, xp) {
shared_ptr(`arrow::DataType`, xp)$..dispatch()
}

#' infer the arrow Array type from an R vector
#'
#' @param x an R vector
#'
#' @return an arrow logical type
#' @export
type <- function(x) {
UseMethod("type")
}

#' @export
type.default <- function(x) {
`arrow::DataType`$dispatch(Array__infer_type(x))
}

#' @export
`type.arrow::Array` <- function(x) x$type

#' @export
`type.arrow::ChunkedArray` <- function(x) x$type

#' @export
`type.arrow::Column` <- function(x) x$type


#----- metadata

#' @title class arrow::FixedWidthType
Expand Down
20 changes: 12 additions & 8 deletions r/R/RcppExports.R

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions r/R/array.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#' @section Usage:
#'
#' ```
#' a <- array(...)
#' a <- array(x)
#'
#' a$IsNull(i)
#' a$IsValid(i)
Expand Down Expand Up @@ -119,16 +119,13 @@

#' create an [arrow::Array][arrow__Array] from an R vector
#'
#' @param \dots Vectors to coerce
#' @param type currently ignored
#' @param x R object
#' @param type Explicit [type][arrow__DataType], or NULL (the default) to infer from the data
#'
#' @importFrom rlang warn
#' @export
array <- function(..., type){
if (!missing(type)) {
warn("The `type` argument is currently ignored")
}
`arrow::Array`$dispatch(Array__from_vector(vctrs::vec_c(...)))
array <- function(x, type = NULL){
`arrow::Array`$dispatch(Array__from_vector(x, type))
}

`arrow::DictionaryArray` <- R6Class("arrow::DictionaryArray", inherit = `arrow::Array`,
Expand Down
6 changes: 3 additions & 3 deletions r/man/array.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion r/man/arrow__Array.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion r/man/arrow__ArrayData.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion r/man/chunked_array.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions r/man/type.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 38 additions & 24 deletions r/src/RcppExports.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading