Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix test
  • Loading branch information
Feng Liu committed Mar 1, 2018
commit 6a962e900a2b9de2e434f2a6ec1eb256ea87a774
10 changes: 3 additions & 7 deletions R/pkg/tests/fulltests/test_sparkSQL.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ markUtf8 <- function(s) {
}

setHiveContext <- function(sc) {
previousSession <- get(".sparkRsession", envir = .sparkREnv)
# In case the spark conf is changed during the test, let's also make a copy of the confs.
previousConf <- callJStatic("org.apache.spark.sql.api.r.SQLUtils", "getSessionConf", previousSession)
if (exists(".testHiveSession", envir = .sparkREnv)) {
hiveSession <- get(".testHiveSession", envir = .sparkREnv)
} else {
Expand All @@ -49,19 +46,16 @@ setHiveContext <- function(sc) {
})
hiveSession <- callJMethod(hiveCtx, "sparkSession")
}
previousSession <- get(".sparkRsession", envir = .sparkREnv)
assign(".sparkRsession", hiveSession, envir = .sparkREnv)
assign(".prevSparkRsession", previousSession, envir = .sparkREnv)
assign(".prevSessionConf", previousConf, envir = .sparkREnv)
hiveSession
}

unsetHiveContext <- function() {
previousSession <- get(".prevSparkRsession", envir = .sparkREnv)
previousConf <- get(".prevSessionConf", envir = .sparkREnv)
callJStatic("org.apache.spark.sql.api.r.SQLUtils", "setSparkContextSessionConf", previousSession, previousConf)
assign(".sparkRsession", previousSession, envir = .sparkREnv)
remove(".prevSparkRsession", envir = .sparkREnv)
remove(".prevSessionConf", envir = .sparkREnv)
}

# Tests for SparkSQL functions in SparkR
Expand All @@ -73,6 +67,8 @@ sparkSession <- if (windows_with_hadoop()) {
sparkR.session(master = sparkRTestMaster, enableHiveSupport = FALSE)
}
sc <- callJStatic("org.apache.spark.sql.api.r.SQLUtils", "getJavaSparkContext", sparkSession)
# materialize the catalog implementation
listTables()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are calling sparkR.session(master = sparkRTestMaster, enableHiveSupport = FALSE) is almost every other test files - does the same apply in those other places?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_sparkSQL.R is the only one uses newJObject("org.apache.spark.sql.hive.test.TestHiveContext", ssc, FALSE) on the ssc, so the catalog impl spark conf is changed. So ``test_sparkSQL.R` is the only one broken.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


mockLines <- c("{\"name\":\"Michael\"}",
"{\"name\":\"Andy\", \"age\":30}",
Expand Down