Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 85225200C5B for ; Thu, 27 Apr 2017 19:19:54 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 83BA7160BA7; Thu, 27 Apr 2017 17:19:54 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id CB442160B9E for ; Thu, 27 Apr 2017 19:19:53 +0200 (CEST) Received: (qmail 80428 invoked by uid 500); 27 Apr 2017 17:19:53 -0000 Mailing-List: contact reviews-help@spark.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list reviews@spark.apache.org Received: (qmail 80417 invoked by uid 99); 27 Apr 2017 17:19:52 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Apr 2017 17:19:52 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id ADC34DFDAC; Thu, 27 Apr 2017 17:19:52 +0000 (UTC) From: felixcheung To: reviews@spark.apache.org Reply-To: reviews@spark.apache.org References: In-Reply-To: Subject: [GitHub] spark pull request #17783: [SPARK-20490][SPARKR][WIP] Add R wrappers for eqN... Content-Type: text/plain Message-Id: <20170427171952.ADC34DFDAC@git1-us-west.apache.org> Date: Thu, 27 Apr 2017 17:19:52 +0000 (UTC) archived-at: Thu, 27 Apr 2017 17:19:54 -0000 Github user felixcheung commented on a diff in the pull request: https://github.com/apache/spark/pull/17783#discussion_r113754078 --- 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 -- does this not conflict with any existing R operator? --- 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