Skip to content

Commit cfc9e02

Browse files
committed
Spark-7435[R]: updated patch for review comments
1 parent 62becc1 commit cfc9e02

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

R/pkg/R/DataFrame.R

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,46 +147,47 @@ setMethod("isLocal",
147147
callJMethod(x@sdf, "isLocal")
148148
})
149149

150-
#' show
150+
#' showDF
151151
#'
152152
#' Print the first numRows rows of a DataFrame
153153
#'
154154
#' @param x A SparkSQL DataFrame
155155
#' @param numRows The number of rows to print. Defaults to 20.
156156
#'
157-
#' @rdname show
157+
#' @rdname showDF
158158
#' @export
159159
#' @examples
160160
#'\dontrun{
161161
#' sc <- sparkR.init()
162162
#' sqlCtx <- sparkRSQL.init(sc)
163163
#' path <- "path/to/file.json"
164164
#' df <- jsonFile(sqlCtx, path)
165-
#' show(df)
165+
#' showDF(df)
166166
#'}
167-
setMethod("show",
167+
setMethod("showDF",
168168
signature(x = "DataFrame"),
169169
function(x, numRows = 20) {
170-
callJMethod(x@sdf, "showString", numToInt(numRows))
170+
s <- callJMethod(x@sdf, "showString", numToInt(numRows))
171+
cat(s)
171172
})
172173

173-
#' showDF
174+
#' show
174175
#'
175176
#' Print the DataFrame column names and types
176177
#'
177178
#' @param x A SparkSQL DataFrame
178179
#'
179-
#' @rdname showDF
180+
#' @rdname show
180181
#' @export
181182
#' @examples
182183
#'\dontrun{
183184
#' sc <- sparkR.init()
184185
#' sqlCtx <- sparkRSQL.init(sc)
185186
#' path <- "path/to/file.json"
186187
#' df <- jsonFile(sqlCtx, path)
187-
#' showDF
188+
#' show
188189
#'}
189-
setMethod("showDF", "DataFrame",
190+
setMethod("show", "DataFrame",
190191
function(object) {
191192
cols <- lapply(dtypes(object), function(l) {
192193
paste(l, collapse = ":")

R/pkg/inst/tests/test_sparkSQL.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,10 @@ test_that("toJSON() returns an RDD of the correct values", {
639639
expect_equal(collect(testRDD)[[1]], mockLines[1])
640640
})
641641

642-
test_that("show()", {
642+
test_that("showDF()", {
643643
df <- jsonFile(sqlCtx, jsonPath)
644-
expect_output(show(df), "+----+-------+\n| age| name|\n+----+-------+\n|null|Michael|\n| 30| Andy|\n| 19| Justin|\n+----+-------+\n")
644+
s <- capture.output(showDF(df))
645+
expect_output(s , "+----+-------+\n| age| name|\n+----+-------+\n|null|Michael|\n| 30| Andy|\n| 19| Justin|\n+----+-------+\n")
645646
})
646647

647648
test_that("isLocal()", {

0 commit comments

Comments
 (0)