Github user sun-rui commented on a diff in the pull request:
https://github.com/apache/spark/pull/10220#discussion_r61374122
--- Diff: R/pkg/R/DataFrame.R ---
@@ -1451,17 +1451,54 @@ setMethod("mutate",
function(.data, ...) {
x <- .data
cols <- list(...)
- stopifnot(length(cols) > 0)
- stopifnot(class(cols[[1]]) == "Column")
+ if (length(cols) <= 0) {
+ return(x)
+ }
+
+ lapply(cols, function(col) {
+ stopifnot(class(col) == "Column")
+ })
+
+ # Check if there is any duplicated column name in the DataFrame
+ dfCols <- columns(x)
+ if (length(unique(dfCols)) != length(dfCols)) {
+ stop("Error: found duplicated column name in the DataFrame")
+ }
+
+ # TODO: simplify the implementation of this method after
SPARK-12225 is resolved.
+
+ # For named arguments, use the names for arguments as the
column names
+ # For unnamed arguments, use the argument symbols as the
column names
+ args <- sapply(substitute(list(...))[-1], deparse)
--- End diff --
I did use cols. But the result is not correct. I have to use list(...)
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]