Skip to content

Commit 835a770

Browse files
rekhajoshmshivaram
authored andcommitted
[SPARK-7435] [SPARKR] Make DataFrame.show() consistent with that of Scala and pySpark
Author: Joshi <[email protected]> Author: Rekha Joshi <[email protected]> Closes apache#5989 from rekhajoshm/fix/SPARK-7435 and squashes the following commits: cfc9e02 [Joshi] Spark-7435[R]: updated patch for review comments 62becc1 [Joshi] SPARK-7435: Update to DataFrame e3677c9 [Rekha Joshi] Merge pull request #1 from apache/master (cherry picked from commit b94a933) Signed-off-by: Shivaram Venkataraman <[email protected]>
1 parent ed40ab5 commit 835a770

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

R/pkg/R/DataFrame.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ setMethod("isLocal",
150150
callJMethod(x@sdf, "isLocal")
151151
})
152152

153-
#' ShowDF
153+
#' showDF
154154
#'
155155
#' Print the first numRows rows of a DataFrame
156156
#'
@@ -170,7 +170,8 @@ setMethod("isLocal",
170170
setMethod("showDF",
171171
signature(x = "DataFrame"),
172172
function(x, numRows = 20) {
173-
callJMethod(x@sdf, "showString", numToInt(numRows))
173+
s <- callJMethod(x@sdf, "showString", numToInt(numRows))
174+
cat(s)
174175
})
175176

176177
#' show
@@ -187,7 +188,7 @@ setMethod("showDF",
187188
#' sqlCtx <- sparkRSQL.init(sc)
188189
#' path <- "path/to/file.json"
189190
#' df <- jsonFile(sqlCtx, path)
190-
#' show(df)
191+
#' df
191192
#'}
192193
setMethod("show", "DataFrame",
193194
function(object) {

R/pkg/inst/tests/test_sparkSQL.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,8 @@ test_that("toJSON() returns an RDD of the correct values", {
653653

654654
test_that("showDF()", {
655655
df <- jsonFile(sqlCtx, jsonPath)
656-
expect_output(showDF(df), "+----+-------+\n| age| name|\n+----+-------+\n|null|Michael|\n| 30| Andy|\n| 19| Justin|\n+----+-------+\n")
656+
s <- capture.output(showDF(df))
657+
expect_output(s , "+----+-------+\n| age| name|\n+----+-------+\n|null|Michael|\n| 30| Andy|\n| 19| Justin|\n+----+-------+\n")
657658
})
658659

659660
test_that("isLocal()", {

0 commit comments

Comments
 (0)