Github user sun-rui commented on a diff in the pull request: https://github.com/apache/spark/pull/8920#discussion_r41112848 --- Diff: R/pkg/R/DataFrame.R --- @@ -1304,24 +1306,62 @@ setClassUnion("characterOrColumn", c("character", "Column")) #' path <- "path/to/file.json" #' df <- jsonFile(sqlContext, path) #' arrange(df, df$col1) -#' arrange(df, "col1") #' arrange(df, asc(df$col1), desc(abs(df$col2))) +#' arrange(df, "col1") +#' arrange(df, "col2", FALSE) +#' arrange(df, "col1", decreasing=TRUE) +#' arrange(df, "col1", "col2", c(TRUE, FALSE)) #' } setMethod("arrange", - signature(x = "DataFrame", col = "characterOrColumn"), + signature(x = "DataFrame", col="Column"), function(x, col, ...) { - if (class(col) == "character") { - sdf <- callJMethod(x@sdf, "sort", col, list(...)) - } else if (class(col) == "Column") { jcols <- lapply(list(col, ...), function(c) { c@jc }) - sdf <- callJMethod(x@sdf, "sort", jcols) - } + + sdf <- callJMethod(x@sdf, "sort", jcols) dataFrame(sdf) }) #' @rdname arrange +#' @export +setMethod("arrange", + signature(x = "DataFrame", col="character"), + function(x, col, ..., decreasing=FALSE) { + + # all sorting columns + by <- list(col, ...) + + # extracting the last element and uses it as decreasing if it is boolean --- End diff -- remove this block of code. Sorting direction must be specified by "decreasing = ". No need to check if last element in "..." is decreasing or not.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org