Skip to content
Snippets Groups Projects
Commit b94a9337 authored by Joshi's avatar Joshi Committed by Shivaram Venkataraman
Browse files

[SPARK-7435] [SPARKR] Make DataFrame.show() consistent with that of Scala and pySpark

Author: Joshi <rekhajoshm@gmail.com>
Author: Rekha Joshi <rekhajoshm@gmail.com>

Closes #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
parent 028ad4bd
No related branches found
No related tags found
No related merge requests found
...@@ -150,7 +150,7 @@ setMethod("isLocal", ...@@ -150,7 +150,7 @@ setMethod("isLocal",
callJMethod(x@sdf, "isLocal") callJMethod(x@sdf, "isLocal")
}) })
#' ShowDF #' showDF
#' #'
#' Print the first numRows rows of a DataFrame #' Print the first numRows rows of a DataFrame
#' #'
...@@ -170,7 +170,8 @@ setMethod("isLocal", ...@@ -170,7 +170,8 @@ setMethod("isLocal",
setMethod("showDF", setMethod("showDF",
signature(x = "DataFrame"), signature(x = "DataFrame"),
function(x, numRows = 20) { function(x, numRows = 20) {
callJMethod(x@sdf, "showString", numToInt(numRows)) s <- callJMethod(x@sdf, "showString", numToInt(numRows))
cat(s)
}) })
#' show #' show
...@@ -187,7 +188,7 @@ setMethod("showDF", ...@@ -187,7 +188,7 @@ setMethod("showDF",
#' sqlCtx <- sparkRSQL.init(sc) #' sqlCtx <- sparkRSQL.init(sc)
#' path <- "path/to/file.json" #' path <- "path/to/file.json"
#' df <- jsonFile(sqlCtx, path) #' df <- jsonFile(sqlCtx, path)
#' show(df) #' df
#'} #'}
setMethod("show", "DataFrame", setMethod("show", "DataFrame",
function(object) { function(object) {
......
...@@ -653,7 +653,8 @@ test_that("toJSON() returns an RDD of the correct values", { ...@@ -653,7 +653,8 @@ test_that("toJSON() returns an RDD of the correct values", {
test_that("showDF()", { test_that("showDF()", {
df <- jsonFile(sqlCtx, jsonPath) df <- jsonFile(sqlCtx, jsonPath)
expect_output(showDF(df), "+----+-------+\n| age| name|\n+----+-------+\n|null|Michael|\n| 30| Andy|\n| 19| Justin|\n+----+-------+\n") s <- capture.output(showDF(df))
expect_output(s , "+----+-------+\n| age| name|\n+----+-------+\n|null|Michael|\n| 30| Andy|\n| 19| Justin|\n+----+-------+\n")
}) })
test_that("isLocal()", { test_that("isLocal()", {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment