Skip to content

Commit 07d0dbc

Browse files
Sun RuiDavies Liu
Sun Rui
authored and
Davies Liu
committed
[SPARKR-244] Fix test failure after integration of subtract() and subtractByKey() for RDD.
1 parent 7e8caa3 commit 07d0dbc

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

R/pkg/NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ exportMethods("columns",
122122
"show",
123123
"showDF",
124124
"sortDF",
125+
"except",
125126
"toJSON",
126127
"toRDD",
127128
"unionAll",

R/pkg/R/DataFrame.R

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,32 +1141,33 @@ setMethod("intersect",
11411141
dataFrame(intersected)
11421142
})
11431143

1144-
#' Subtract
1144+
#' except
11451145
#'
11461146
#' Return a new DataFrame containing rows in this DataFrame
11471147
#' but not in another DataFrame. This is equivalent to `EXCEPT` in SQL.
11481148
#'
11491149
#' @param x A Spark DataFrame
11501150
#' @param y A Spark DataFrame
1151-
#' @return A DataFrame containing the result of the subtract operation.
1152-
#' @rdname subtract
1151+
#' @return A DataFrame containing the result of the except operation.
1152+
#' @rdname except
11531153
#' @export
11541154
#' @examples
11551155
#'\dontrun{
11561156
#' sc <- sparkR.init()
11571157
#' sqlCtx <- sparkRSQL.init(sc)
11581158
#' df1 <- jsonFile(sqlCtx, path)
11591159
#' df2 <- jsonFile(sqlCtx, path2)
1160-
#' subtractDF <- subtract(df, df2)
1160+
#' exceptDF <- except(df, df2)
11611161
#' }
1162+
setGeneric("except", function(x, y) { standardGeneric("except") })
11621163

1163-
#' @rdname subtract
1164+
#' @rdname except
11641165
#' @export
1165-
setMethod("subtract",
1166-
signature(x = "DataFrame", other = "DataFrame"),
1167-
function(x, other) {
1168-
subtracted <- callJMethod(x@sdf, "except", other@sdf)
1169-
dataFrame(subtracted)
1166+
setMethod("except",
1167+
signature(x = "DataFrame", y = "DataFrame"),
1168+
function(x, y) {
1169+
excepted <- callJMethod(x@sdf, "except", y@sdf)
1170+
dataFrame(excepted)
11701171
})
11711172

11721173
#' Save the contents of the DataFrame to a data source

R/pkg/inst/tests/test_sparkSQL.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ test_that("isLocal()", {
644644
expect_false(isLocal(df))
645645
})
646646

647-
test_that("unionAll(), subtract(), and intersect() on a DataFrame", {
647+
test_that("unionAll(), except(), and intersect() on a DataFrame", {
648648
df <- jsonFile(sqlCtx, jsonPath)
649649

650650
lines <- c("{\"name\":\"Bob\", \"age\":24}",
@@ -659,10 +659,10 @@ test_that("unionAll(), subtract(), and intersect() on a DataFrame", {
659659
expect_true(count(unioned) == 6)
660660
expect_true(first(unioned)$name == "Michael")
661661

662-
subtracted <- sortDF(subtract(df, df2), desc(df$age))
662+
excepted <- sortDF(except(df, df2), desc(df$age))
663663
expect_true(inherits(unioned, "DataFrame"))
664-
expect_true(count(subtracted) == 2)
665-
expect_true(first(subtracted)$name == "Justin")
664+
expect_true(count(excepted) == 2)
665+
expect_true(first(excepted)$name == "Justin")
666666

667667
intersected <- sortDF(intersect(df, df2), df$age)
668668
expect_true(inherits(unioned, "DataFrame"))

0 commit comments

Comments
 (0)