Skip to content

Commit

Permalink
remove SQLContext on stop
Browse files Browse the repository at this point in the history
  • Loading branch information
saurfang committed Oct 21, 2015
1 parent 8e82e59 commit 7f51549
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions R/pkg/R/sparkR.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ sparkR.stop <- function() {
sc <- get(".sparkRjsc", envir = env)
callJMethod(sc, "stop")
rm(".sparkRjsc", envir = env)

if (exists(".sparkRSQLsc", envir = env)) {
rm(".sparkRSQLsc", envir = env)
}

if (exists(".sparkRHivesc", envir = env)) {
rm(".sparkRHivesc", envir = env)
}
}

if (exists(".backendLaunched", envir = env)) {
Expand Down
10 changes: 10 additions & 0 deletions R/pkg/inst/tests/test_context.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ test_that("repeatedly starting and stopping SparkR", {
}
})

test_that("repeatedly starting and stopping SparkR SQL", {
for (i in 1:4) {
sc <- sparkR.init()
sqlContext <- sparkRSQL.init(sc)
df <- createDataFrame(sqlContext, data.frame(a = 1:20))
expect_equal(count(df), 20)
sparkR.stop()
}
})

test_that("rdd GC across sparkR.stop", {
sparkR.stop()
sc <- sparkR.init() # sc should get id 0
Expand Down

0 comments on commit 7f51549

Please sign in to comment.