ianmcook commented on a change in pull request #10559:
URL: https://github.com/apache/arrow/pull/10559#discussion_r655417025
##########
File path: r/R/dplyr-arrange.R
##########
@@ -77,6 +77,10 @@ find_and_remove_desc <- function(quosure) {
# remove enclosing parentheses
expr <- expr[[2]]
} else if (identical(expr[[1]], quote(desc))) {
+ # ensure desc() has only one argument
+ if (length(expr) > 2) {
+ stop("desc() expects only one argument", call. = FALSE)
+ }
Review comment:
Yes, that's correct 👍
##########
File path: r/R/dplyr-arrange.R
##########
@@ -77,6 +77,10 @@ find_and_remove_desc <- function(quosure) {
# remove enclosing parentheses
expr <- expr[[2]]
} else if (identical(expr[[1]], quote(desc))) {
+ # ensure desc() has only one argument
+ if (length(expr) > 2) {
+ stop("desc() expects only one argument", call. = FALSE)
+ }
Review comment:
Also, because this might be confusing: when an R expression is a
function call, having length == 2 means it has one and only one argument.
##########
File path: r/R/dplyr-arrange.R
##########
@@ -77,6 +77,10 @@ find_and_remove_desc <- function(quosure) {
# remove enclosing parentheses
expr <- expr[[2]]
} else if (identical(expr[[1]], quote(desc))) {
+ # ensure desc() has only one argument
+ if (length(expr) > 2) {
+ stop("desc() expects only one argument", call. = FALSE)
+ }
Review comment:
Also, because this might be confusing: when an R expression is a
function call, having length == 2 means it has one and only one argument.
```r
length(quote(foo(bar)))
## [1] 2
```
##########
File path: r/R/dplyr-arrange.R
##########
@@ -77,6 +77,10 @@ find_and_remove_desc <- function(quosure) {
# remove enclosing parentheses
expr <- expr[[2]]
} else if (identical(expr[[1]], quote(desc))) {
+ # ensure desc() has only one argument
Review comment:
```suggestion
# ensure desc() has only one argument (when an R expression is a
function
# call, length == 2 means it has one argument)
```
##########
File path: r/R/dplyr-arrange.R
##########
@@ -77,6 +77,10 @@ find_and_remove_desc <- function(quosure) {
# remove enclosing parentheses
expr <- expr[[2]]
} else if (identical(expr[[1]], quote(desc))) {
+ # ensure desc() has only one argument
Review comment:
```suggestion
# ensure desc() has only one argument (when an R expression is a
function
# call, length == 2 means it has exactly one argument)
```
##########
File path: r/R/dplyr-arrange.R
##########
@@ -77,6 +77,10 @@ find_and_remove_desc <- function(quosure) {
# remove enclosing parentheses
expr <- expr[[2]]
} else if (identical(expr[[1]], quote(desc))) {
+ # ensure desc() has only one argument
+ if (length(expr) > 2) {
+ stop("desc() expects only one argument", call. = FALSE)
+ }
Review comment:
Comment added in ae132c6
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]