You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by olarayej <gi...@git.apache.org> on 2016/02/16 19:17:01 UTC

[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

GitHub user olarayej opened a pull request:

    https://github.com/apache/spark/pull/11220

    [SPARK-13327][SPARKR] Added parameter validations for colnames<-

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/olarayej/spark SPARK-13312-3

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/11220.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #11220
    
----
commit e8c64156e468105a4323f59d1ece87c8fb6662f4
Author: Oscar D. Lara Yejas <od...@oscars-mbp.usca.ibm.com>
Date:   2016-02-16T18:14:40Z

    Added parameter validations for colnames<-

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by sun-rui <gi...@git.apache.org>.
Github user sun-rui commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11220#discussion_r53749397
  
    --- 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 --
    
    It is interesting. @felixcheung, do you know the reason behind this?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11220#issuecomment-187404907
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/51676/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by sun-rui <gi...@git.apache.org>.
Github user sun-rui commented on the pull request:

    https://github.com/apache/spark/pull/11220#issuecomment-194111890
  
    LGTM


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by felixcheung <gi...@git.apache.org>.
Github user felixcheung commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11220#discussion_r53126613
  
    --- Diff: R/pkg/R/DataFrame.R ---
    @@ -303,8 +303,28 @@ setMethod("colnames",
     #' @rdname columns
     #' @name colnames<-
     setMethod("colnames<-",
    -          signature(x = "DataFrame", value = "character"),
    +          signature(x = "DataFrame"),
               function(x, value) {
    +
    +            # Check parameter integrity
    +            if (class(value) != "character") {
    +              stop("Invalid column names.")
    +            }
    +
    +            if (length(value) != ncol(x)) {
    +              stop(
    +                "Column names must have the same length as the number of columns in the dataset.")
    +            }
    +
    +            if (any(is.na(value))) {
    +              stop("Column names cannot be NA.")
    +            }
    +
    +            # Check if the column names have . in it
    +            if (any(regexec(".", value, fixed=TRUE)[[1]][1] != -1)) {
    --- End diff --
    
    This might seem rather restrictive? As this is possibly fixed by https://issues.apache.org/jira/browse/SPARK-11976
    Instead of hardcoding the check here, why not just let this through? As of now a column cannot have '.' in it anyway


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/11220


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11220#issuecomment-184812178
  
    **[Test build #51373 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/51373/consoleFull)** for PR 11220 at commit [`e8c6415`](https://github.com/apache/spark/commit/e8c64156e468105a4323f59d1ece87c8fb6662f4).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11220#issuecomment-187396910
  
    **[Test build #51676 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/51676/consoleFull)** for PR 11220 at commit [`07e541b`](https://github.com/apache/spark/commit/07e541b7e55a322ea7c74e230ee897ebe9584197).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by sun-rui <gi...@git.apache.org>.
Github user sun-rui commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11220#discussion_r53115143
  
    --- 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 would prefer keeping the current signature instead of checking the class of the parameter inside the method.
    @felixcheung, what's your opinion?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by sun-rui <gi...@git.apache.org>.
Github user sun-rui commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11220#discussion_r53132543
  
    --- Diff: R/pkg/R/DataFrame.R ---
    @@ -303,8 +303,28 @@ setMethod("colnames",
     #' @rdname columns
     #' @name colnames<-
     setMethod("colnames<-",
    -          signature(x = "DataFrame", value = "character"),
    +          signature(x = "DataFrame"),
               function(x, value) {
    +
    +            # Check parameter integrity
    +            if (class(value) != "character") {
    +              stop("Invalid column names.")
    +            }
    +
    +            if (length(value) != ncol(x)) {
    +              stop(
    +                "Column names must have the same length as the number of columns in the dataset.")
    +            }
    +
    +            if (any(is.na(value))) {
    +              stop("Column names cannot be NA.")
    +            }
    +
    +            # Check if the column names have . in it
    +            if (any(regexec(".", value, fixed=TRUE)[[1]][1] != -1)) {
    --- End diff --
    
    I think this is OK as SPARK-11976 is not fixed. This restriction can be removed later, if columns having '.' can be accessed transparently


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by olarayej <gi...@git.apache.org>.
Github user olarayej commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11220#discussion_r53373470
  
    --- Diff: R/pkg/R/DataFrame.R ---
    @@ -303,8 +303,28 @@ setMethod("colnames",
     #' @rdname columns
     #' @name colnames<-
     setMethod("colnames<-",
    -          signature(x = "DataFrame", value = "character"),
    +          signature(x = "DataFrame"),
               function(x, value) {
    +
    +            # Check parameter integrity
    +            if (class(value) != "character") {
    +              stop("Invalid column names.")
    +            }
    +
    +            if (length(value) != ncol(x)) {
    +              stop(
    +                "Column names must have the same length as the number of columns in the dataset.")
    +            }
    +
    +            if (any(is.na(value))) {
    +              stop("Column names cannot be NA.")
    +            }
    +
    +            # Check if the column names have . in it
    +            if (any(regexec(".", value, fixed=TRUE)[[1]][1] != -1)) {
    --- End diff --
    
    @felixcheung @sun-rui Thanks for your input. Right now if I assign column names containing "." character, any subsequent operation on the DataFrame will fail.
    
    Now, regarding @felixcheung's comment on the test case, right now there are two test cases with str() and with() expecting colnames of iris to be "Sepal_Length", ..., etc. Those will be broken when they fix SPARK-11976. No need to add more.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by olarayej <gi...@git.apache.org>.
Github user olarayej commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11220#discussion_r55481841
  
    --- 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 --
    
    Thanks @felixcheung for investigating this further!


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11220#issuecomment-187404697
  
    **[Test build #51676 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/51676/consoleFull)** for PR 11220 at commit [`07e541b`](https://github.com/apache/spark/commit/07e541b7e55a322ea7c74e230ee897ebe9584197).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by felixcheung <gi...@git.apache.org>.
Github user felixcheung commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11220#discussion_r53573498
  
    --- Diff: R/pkg/R/DataFrame.R ---
    @@ -303,8 +303,28 @@ setMethod("colnames",
     #' @rdname columns
     #' @name colnames<-
     setMethod("colnames<-",
    -          signature(x = "DataFrame", value = "character"),
    +          signature(x = "DataFrame"),
               function(x, value) {
    +
    +            # Check parameter integrity
    +            if (class(value) != "character") {
    +              stop("Invalid column names.")
    +            }
    +
    +            if (length(value) != ncol(x)) {
    +              stop(
    +                "Column names must have the same length as the number of columns in the dataset.")
    +            }
    +
    +            if (any(is.na(value))) {
    +              stop("Column names cannot be NA.")
    +            }
    +
    +            # Check if the column names have . in it
    +            if (any(regexec(".", value, fixed=TRUE)[[1]][1] != -1)) {
    --- End diff --
    
    that is, also what you have [here](https://github.com/apache/spark/pull/11220/files#diff-3d2a6b9d2b7d84ae179d7ea0f9eca696R694) is also a good test for covering this case.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by olarayej <gi...@git.apache.org>.
Github user olarayej commented on the pull request:

    https://github.com/apache/spark/pull/11220#issuecomment-195127575
  
    Thanks, @shivaram!


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by olarayej <gi...@git.apache.org>.
Github user olarayej commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11220#discussion_r53375517
  
    --- 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 --
    
    The reason I added this was because of this:
    
    > colnames(iris) <- 1
    Error in `colnames<-`(`*tmp*`, value = 1) : 
      'dimnames' applied to non-array
    
    After I ran that, I saw this:
    > showMethods("colnames<-")
    Function: colnames<- (package SparkR)
    x="ANY", value="ANY"
    x="DataFrame", value="character"
    x="DataFrame", value="numeric"
        (inherited from: x="ANY", value="ANY")
    
    So looks like R automatically adds definitions of colnames<- if value is other than character.
    
    This does not happen with coltypes<-, as it's not part of base package and doesn't have an (ANY,ANY) signature.
    
    > coltypes(irisDF) <- 1
    Error in (function (classes, fdef, mtable)  : 
      unable to find an inherited method for function ‘coltypes<-’ for signature ‘"DataFrame", "numeric"’


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by olarayej <gi...@git.apache.org>.
Github user olarayej commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11220#discussion_r53701739
  
    --- Diff: R/pkg/R/DataFrame.R ---
    @@ -303,8 +303,28 @@ setMethod("colnames",
     #' @rdname columns
     #' @name colnames<-
     setMethod("colnames<-",
    -          signature(x = "DataFrame", value = "character"),
    +          signature(x = "DataFrame"),
               function(x, value) {
    +
    +            # Check parameter integrity
    +            if (class(value) != "character") {
    +              stop("Invalid column names.")
    +            }
    +
    +            if (length(value) != ncol(x)) {
    +              stop(
    +                "Column names must have the same length as the number of columns in the dataset.")
    +            }
    +
    +            if (any(is.na(value))) {
    +              stop("Column names cannot be NA.")
    +            }
    +
    +            # Check if the column names have . in it
    +            if (any(regexec(".", value, fixed=TRUE)[[1]][1] != -1)) {
    --- End diff --
    
    Done. @sun-rui, @felixcheung. Shall we merge this PR?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by felixcheung <gi...@git.apache.org>.
Github user felixcheung commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11220#discussion_r53200774
  
    --- Diff: R/pkg/R/DataFrame.R ---
    @@ -303,8 +303,28 @@ setMethod("colnames",
     #' @rdname columns
     #' @name colnames<-
     setMethod("colnames<-",
    -          signature(x = "DataFrame", value = "character"),
    +          signature(x = "DataFrame"),
               function(x, value) {
    +
    +            # Check parameter integrity
    +            if (class(value) != "character") {
    +              stop("Invalid column names.")
    +            }
    +
    +            if (length(value) != ncol(x)) {
    +              stop(
    +                "Column names must have the same length as the number of columns in the dataset.")
    +            }
    +
    +            if (any(is.na(value))) {
    +              stop("Column names cannot be NA.")
    +            }
    +
    +            # Check if the column names have . in it
    +            if (any(regexec(".", value, fixed=TRUE)[[1]][1] != -1)) {
    --- End diff --
    
    Then I would suggest creating a new test case with colnames to check that a DataFrame created from iris would have column names with . replaced with _.
    This test case would be broken in the event that SPARK-11976 is fixed to remind us to remove this check in colnames. Otherwise it is very easy to forget.
    
      


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by felixcheung <gi...@git.apache.org>.
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by felixcheung <gi...@git.apache.org>.
Github user felixcheung commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11220#discussion_r53417181
  
    --- Diff: R/pkg/R/DataFrame.R ---
    @@ -303,8 +303,28 @@ setMethod("colnames",
     #' @rdname columns
     #' @name colnames<-
     setMethod("colnames<-",
    -          signature(x = "DataFrame", value = "character"),
    +          signature(x = "DataFrame"),
               function(x, value) {
    +
    +            # Check parameter integrity
    +            if (class(value) != "character") {
    +              stop("Invalid column names.")
    +            }
    +
    +            if (length(value) != ncol(x)) {
    +              stop(
    +                "Column names must have the same length as the number of columns in the dataset.")
    +            }
    +
    +            if (any(is.na(value))) {
    +              stop("Column names cannot be NA.")
    +            }
    +
    +            # Check if the column names have . in it
    +            if (any(regexec(".", value, fixed=TRUE)[[1]][1] != -1)) {
    --- End diff --
    
    To clarify, I think having a specific test of colnames with iris will help to realize that this check [code](https://github.com/apache/spark/pull/11220/files#diff-508641a8bd6c6b59f3e77c80cdcfa6a9R324) is in place and should be removed, if and when SPARK-11976 is fixed. Otherwise only tests with str and with will be fixed. Does that make sense?



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11220#issuecomment-187404906
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11220#issuecomment-184821483
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/51373/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by olarayej <gi...@git.apache.org>.
Github user olarayej commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11220#discussion_r53504008
  
    --- Diff: R/pkg/R/DataFrame.R ---
    @@ -303,8 +303,28 @@ setMethod("colnames",
     #' @rdname columns
     #' @name colnames<-
     setMethod("colnames<-",
    -          signature(x = "DataFrame", value = "character"),
    +          signature(x = "DataFrame"),
               function(x, value) {
    +
    +            # Check parameter integrity
    +            if (class(value) != "character") {
    +              stop("Invalid column names.")
    +            }
    +
    +            if (length(value) != ncol(x)) {
    +              stop(
    +                "Column names must have the same length as the number of columns in the dataset.")
    +            }
    +
    +            if (any(is.na(value))) {
    +              stop("Column names cannot be NA.")
    +            }
    +
    +            # Check if the column names have . in it
    +            if (any(regexec(".", value, fixed=TRUE)[[1]][1] != -1)) {
    --- End diff --
    
    @felixcheung Not sure I follow your idea. Is this what you refer to?
    
    # Note: if this test is broken, remove check for "." character on colnames<- method
    expect_equal(colnames(irisDF)[1] == "Sepal_Length"))


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by felixcheung <gi...@git.apache.org>.
Github user felixcheung commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11220#discussion_r53126056
  
    --- 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 agree - letting R do type matching for the method signature seems like a better approach?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by olarayej <gi...@git.apache.org>.
Github user olarayej commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11220#discussion_r55418947
  
    --- Diff: R/pkg/R/DataFrame.R ---
    @@ -303,8 +303,28 @@ setMethod("colnames",
     #' @rdname columns
     #' @name colnames<-
     setMethod("colnames<-",
    -          signature(x = "DataFrame", value = "character"),
    +          signature(x = "DataFrame"),
               function(x, value) {
    +
    +            # Check parameter integrity
    +            if (class(value) != "character") {
    +              stop("Invalid column names.")
    +            }
    +
    +            if (length(value) != ncol(x)) {
    +              stop(
    +                "Column names must have the same length as the number of columns in the dataset.")
    +            }
    +
    +            if (any(is.na(value))) {
    +              stop("Column names cannot be NA.")
    +            }
    +
    +            # Check if the column names have . in it
    +            if (any(regexec(".", value, fixed=TRUE)[[1]][1] != -1)) {
    --- End diff --
    
    @sun-rui @felixcheung @shivaram Folks: this is a really simple thing. Shall we merge it?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by shivaram <gi...@git.apache.org>.
Github user shivaram commented on the pull request:

    https://github.com/apache/spark/pull/11220#issuecomment-195125133
  
    LGTM. Merging this.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/11220#issuecomment-184821246
  
    **[Test build #51373 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/51373/consoleFull)** for PR 11220 at commit [`e8c6415`](https://github.com/apache/spark/commit/e8c64156e468105a4323f59d1ece87c8fb6662f4).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by olarayej <gi...@git.apache.org>.
Github user olarayej commented on the pull request:

    https://github.com/apache/spark/pull/11220#issuecomment-187318737
  
    Jenkins, retest please


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-13327][SPARKR] Added parameter validati...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/11220#issuecomment-184821476
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org