Github user felixcheung commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11220#discussion_r55474213
  
    --- Diff: R/pkg/R/DataFrame.R ---
    @@ -303,8 +303,28 @@ setMethod("colnames",
     #' @rdname columns
     #' @name colnames<-
     setMethod("colnames<-",
    -          signature(x = "DataFrame", value = "character"),
    --- End diff --
    
    I think in this case the base:: definition is implemented in such a way 
that it *should* (or at least it attempts to) handle different parameter types:
    
    ```
    > getMethod("colnames<-")
    Method Definition (Class "derivedDefaultMethod"):
    
    function (x, value)
    {
        if (is.data.frame(x)) {
            names(x) <- value
        }
        else {
            dn <- dimnames(x)
            if (is.null(dn)) {
                if (is.null(value))
                    return(x)
                if ((nd <- length(dim(x))) < 2L)
                    stop("attempt to set 'colnames' on an object with less than 
two dimensions")
                dn <- vector("list", nd)
            }
            if (length(dn) < 2L)
                stop("attempt to set 'colnames' on an object with less than two 
dimensions")
            if (is.null(value))
                dn[2L] <- list(NULL)
            else dn[[2L]] <- value
            dimnames(x) <- dn
        }
        x
    }
    <bytecode: 0x34c9058>
    <environment: namespace:base>
    
    Signatures:
            x     value
    target  "ANY" "ANY"
    defined "ANY" "ANY"
    ```
    
    So from what I can see the error you see actually comes from the base 
implement, as "sort of" expected. Though I'm ok if we are to add explicit 
checks to make the error more clear for the user.


---
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]

Reply via email to