spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zero323 <...@git.apache.org>
Subject [GitHub] spark pull request #17783: [SPARK-20490][SPARKR][WIP] Add R wrappers for eqN...
Date Thu, 27 Apr 2017 19:05:31 GMT
Github user zero323 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17783#discussion_r113777544
  
    --- Diff: R/pkg/R/column.R ---
    @@ -302,3 +301,65 @@ setMethod("otherwise",
                 jc <- callJMethod(x@jc, "otherwise", value)
                 column(jc)
               })
    +
    +#' \%<=>\%
    +#'
    +#' Equality test that is safe for null values.
    +#'
    +#' Can be used, unlike standard equality operator, to perform null-safe joins.
    +#' Equivalent to Scala \code{Column.<=>} and \code{Column.eqNullSafe}.
    +#'
    +#' @param x a Column
    +#' @param value a value to compare
    +#' @rdname eq_null_safe
    +#' @name %<=>%
    +#' @aliases %<=>%,Column-method
    +#' @export
    +#' @examples
    +#' \dontrun{
    +#' df1 <- createDataFrame(data.frame(
    +#'   x = c(1, NA, 3, NA), y = c(2, 6, 3, NA)
    +#' ))
    +#'
    +#' head(select(df1, df1$x == df1$y, df1$x %<=>% df1$y))
    +#' ##  (x = y) (x <=> y)
    +#' ##1   FALSE     FALSE
    +#' ##2      NA     FALSE
    +#' ##3    TRUE      TRUE
    +#' ##4      NA      TRUE
    +#'
    +#' df2 <- createDataFrame(data.frame(y = c(3, NA)))
    +#' count(join(df1, df2, df1$y == df2$y))
    +#' ## [1] 1
    +#'
    +#' count(join(df1, df2, df1$y %<=>% df2$y))
    +#' ## [1] 2
    +#' }
    +#' @note \%<=>\% since 2.3.0
    +setMethod("%<=>%",
    +          signature(x = "Column", value = "ANY"),
    +          function(x, value) {
    +            value <- if (class(value) == "Column") { value@jc } else { value }
    +            jc <- callJMethod(x@jc, "eqNullSafe", value)
    +            column(jc)
    +          })
    +
    +#' !
    +#'
    +#' @rdname not
    +#' @aliases !,Column-method
    +#' @export
    +#' @examples
    +#' \dontrun{
    +#' df <- createDataFrame(data.frame(x = c(-1, 0, 1)))
    +#'
    +#' head(select(df, !column("x") > 0))
    +#' ##  (NOT (x > 0.0))
    +#' ##1            TRUE
    +#' ##2            TRUE
    +#' ##3           FALSE
    +#' }
    +#' @note ! since 2.3.0
    +setMethod("!",
    --- End diff --
    
    Do you have any thoughts about providing an example output in the docs. I see it makes
Jenkins unhappy 
    
    > R/column.R:325:5: style: Commented code should be removed.
    
    but I believe this is an internal requirement. 


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


Mime
View raw message