Skip to content

Commit

Permalink
Handle rlang:: imports and other namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
nealrichardson committed Oct 12, 2022
1 parent 8e99edb commit 7e4857f
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 19 deletions.
3 changes: 3 additions & 0 deletions r/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ importFrom(rlang,as_quosure)
importFrom(rlang,call2)
importFrom(rlang,call_args)
importFrom(rlang,caller_env)
importFrom(rlang,check_dots_empty)
importFrom(rlang,dots_list)
importFrom(rlang,dots_n)
importFrom(rlang,enexpr)
importFrom(rlang,enexprs)
Expand Down Expand Up @@ -472,6 +474,7 @@ importFrom(stats,na.fail)
importFrom(stats,na.omit)
importFrom(stats,na.pass)
importFrom(stats,quantile)
importFrom(stats,runif)
importFrom(tidyselect,all_of)
importFrom(tidyselect,contains)
importFrom(tidyselect,ends_with)
Expand Down
4 changes: 2 additions & 2 deletions r/R/array.R
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ stop_cant_convert_array <- function(x, type) {
"Can't create Array from object of type %s",
paste(class(x), collapse = " / ")
),
call = rlang::caller_env()
call = caller_env()
)
} else {
abort(
Expand All @@ -358,7 +358,7 @@ stop_cant_convert_array <- function(x, type) {
format(type$code()),
paste(class(x), collapse = " / ")
),
call = rlang::caller_env()
call = caller_env()
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion r/R/arrow-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#' @importFrom rlang expr caller_env is_character quo_name is_quosure enexpr enexprs as_quosure
#' @importFrom rlang is_list call2 is_empty as_function as_label arg_match is_symbol is_call call_args
#' @importFrom rlang quo_set_env quo_get_env is_formula quo_is_call f_rhs parse_expr f_env new_quosure
#' @importFrom rlang new_quosures expr_text
#' @importFrom rlang new_quosures expr_text caller_env check_dots_empty dots_list
#' @importFrom tidyselect vars_pull vars_rename vars_select eval_select
#' @importFrom glue glue
#' @useDynLib arrow, .registration = TRUE
Expand Down
2 changes: 1 addition & 1 deletion r/R/dataset-scan.R
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ map_batches <- function(X, FUN, ..., .schema = NULL, .lazy = FALSE, .data.frame
}
FUN <- as_mapper(FUN)
reader <- as_record_batch_reader(X)
dots <- rlang::list2(...)
dots <- list2(...)

# If no schema is supplied, we have to evaluate the first batch here
if (is.null(.schema)) {
Expand Down
4 changes: 2 additions & 2 deletions r/R/dplyr-funcs-type.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ register_bindings_type_cast <- function() {
# it is difficult to replicate the .name_repair semantics and expanding of
# unnamed data frame arguments in the same way that the tibble() constructor
# does.
args <- rlang::dots_list(..., .named = TRUE, .homonyms = "error")
args <- dots_list(..., .named = TRUE, .homonyms = "error")

build_expr(
"make_struct",
Expand All @@ -151,7 +151,7 @@ register_bindings_type_cast <- function() {
if (!is.null(row.names)) arrow_not_supported("row.names")
if (!is.null(check.rows)) arrow_not_supported("check.rows")

args <- rlang::dots_list(..., .named = fix.empty.names)
args <- dots_list(..., .named = fix.empty.names)
if (is.null(names(args))) {
names(args) <- rep("", length(args))
}
Expand Down
3 changes: 2 additions & 1 deletion r/R/dplyr-funcs.R
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@ call_binding_agg <- function(fun_name, ...) {
agg_funcs[[fun_name]](...)
}

# Called in .onLoad()
#' @importFrom stats runif
create_binding_cache <- function() {
# Called in .onLoad()
.cache$docs <- list()

# Register all available Arrow Compute functions, namespaced as arrow_fun.
Expand Down
20 changes: 10 additions & 10 deletions r/R/dplyr-slice.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
# The following S3 methods are registered on load if dplyr is present

slice_head.arrow_dplyr_query <- function(.data, ..., n, prop) {
if (length(group_vars(.data)) > 0) {
if (length(dplyr::group_vars(.data)) > 0) {
arrow_not_supported("Slicing grouped data")
}
rlang::check_dots_empty()
check_dots_empty()

if (missing(n)) {
n <- prop_to_n(.data, prop)
Expand All @@ -33,10 +33,10 @@ slice_head.arrow_dplyr_query <- function(.data, ..., n, prop) {
slice_head.Dataset <- slice_head.ArrowTabular <- slice_head.RecordBatchReader <- slice_head.arrow_dplyr_query

slice_tail.arrow_dplyr_query <- function(.data, ..., n, prop) {
if (length(group_vars(.data)) > 0) {
if (length(dplyr::group_vars(.data)) > 0) {
arrow_not_supported("Slicing grouped data")
}
rlang::check_dots_empty()
check_dots_empty()

if (missing(n)) {
n <- prop_to_n(.data, prop)
Expand All @@ -47,13 +47,13 @@ slice_tail.arrow_dplyr_query <- function(.data, ..., n, prop) {
slice_tail.Dataset <- slice_tail.ArrowTabular <- slice_tail.RecordBatchReader <- slice_tail.arrow_dplyr_query

slice_min.arrow_dplyr_query <- function(.data, order_by, ..., n, prop, with_ties = TRUE) {
if (length(group_vars(.data)) > 0) {
if (length(dplyr::group_vars(.data)) > 0) {
arrow_not_supported("Slicing grouped data")
}
if (with_ties) {
arrow_not_supported("with_ties = TRUE")
}
rlang::check_dots_empty()
check_dots_empty()

if (missing(n)) {
n <- prop_to_n(.data, prop)
Expand All @@ -64,13 +64,13 @@ slice_min.arrow_dplyr_query <- function(.data, order_by, ..., n, prop, with_ties
slice_min.Dataset <- slice_min.ArrowTabular <- slice_min.RecordBatchReader <- slice_min.arrow_dplyr_query

slice_max.arrow_dplyr_query <- function(.data, order_by, ..., n, prop, with_ties = TRUE) {
if (length(group_vars(.data)) > 0) {
if (length(dplyr::group_vars(.data)) > 0) {
arrow_not_supported("Slicing grouped data")
}
if (with_ties) {
arrow_not_supported("with_ties = TRUE")
}
rlang::check_dots_empty()
check_dots_empty()

if (missing(n)) {
n <- prop_to_n(.data, prop)
Expand All @@ -92,7 +92,7 @@ slice_sample.arrow_dplyr_query <- function(.data,
prop,
weight_by = NULL,
replace = FALSE) {
if (length(group_vars(.data)) > 0) {
if (length(dplyr::group_vars(.data)) > 0) {
arrow_not_supported("Slicing grouped data")
}
if (replace) {
Expand All @@ -103,7 +103,7 @@ slice_sample.arrow_dplyr_query <- function(.data,
# but you'd need to calculate sum(weight_by) in order to normalize
arrow_not_supported("weight_by")
}
rlang::check_dots_empty()
check_dots_empty()

# If we want n rows sampled, we have to convert n to prop, oversample some
# just to make sure we get enough, then head(n)
Expand Down
3 changes: 1 addition & 2 deletions r/R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ as_writable_table <- function(x) {
abort(
"Object must be coercible to an Arrow Table using `as_arrow_table()`",
parent = e,
call = rlang::caller_env(2)
call = caller_env(2)
)
}
)
Expand Down Expand Up @@ -238,7 +238,6 @@ is_compressed <- function(compression) {

# handler function which checks for a number of different read errors
augment_io_error_msg <- function(e, call, schema = NULL, format = NULL) {

msg <- conditionMessage(e)

if (!is.null(schema)) {
Expand Down

0 comments on commit 7e4857f

Please sign in to comment.