Repository: spark
Updated Branches:
  refs/heads/master d7b2b97ad -> 2d2411faa


[SPARK-11672][ML] Set active SQLContext in MLlibTestSparkContext.beforeAll

Still saw some error messages caused by `SQLContext.getOrCreate`:

https://amplab.cs.berkeley.edu/jenkins/job/Spark-Master-SBT/3997/AMPLAB_JENKINS_BUILD_PROFILE=hadoop2.3,label=spark-test/testReport/junit/org.apache.spark.ml.util/JavaDefaultReadWriteSuite/testDefaultReadWrite/

This PR sets the active SQLContext in beforeAll, which is not automatically set 
in `new SQLContext`. This makes `SQLContext.getOrCreate` return the right 
SQLContext.

cc: yhuai

Author: Xiangrui Meng <m...@databricks.com>

Closes #9694 from mengxr/SPARK-11672.3.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/2d2411fa
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/2d2411fa
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/2d2411fa

Branch: refs/heads/master
Commit: 2d2411faa2dd1b7312c4277b2dd9e5678195cfbb
Parents: d7b2b97
Author: Xiangrui Meng <m...@databricks.com>
Authored: Fri Nov 13 13:09:28 2015 -0800
Committer: Xiangrui Meng <m...@databricks.com>
Committed: Fri Nov 13 13:09:28 2015 -0800

----------------------------------------------------------------------
 mllib/src/main/scala/org/apache/spark/ml/util/ReadWrite.scala | 7 +++++--
 .../org/apache/spark/mllib/util/MLlibTestSparkContext.scala   | 1 +
 2 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/2d2411fa/mllib/src/main/scala/org/apache/spark/ml/util/ReadWrite.scala
----------------------------------------------------------------------
diff --git a/mllib/src/main/scala/org/apache/spark/ml/util/ReadWrite.scala 
b/mllib/src/main/scala/org/apache/spark/ml/util/ReadWrite.scala
index 85f888c..ca896ed 100644
--- a/mllib/src/main/scala/org/apache/spark/ml/util/ReadWrite.scala
+++ b/mllib/src/main/scala/org/apache/spark/ml/util/ReadWrite.scala
@@ -48,8 +48,11 @@ private[util] sealed trait BaseReadWrite {
   /**
    * Returns the user-specified SQL context or the default.
    */
-  protected final def sqlContext: SQLContext = optionSQLContext.getOrElse {
-    SQLContext.getOrCreate(SparkContext.getOrCreate())
+  protected final def sqlContext: SQLContext = {
+    if (optionSQLContext.isEmpty) {
+      optionSQLContext = 
Some(SQLContext.getOrCreate(SparkContext.getOrCreate()))
+    }
+    optionSQLContext.get
   }
 
   /** Returns the [[SparkContext]] underlying [[sqlContext]] */

http://git-wip-us.apache.org/repos/asf/spark/blob/2d2411fa/mllib/src/test/scala/org/apache/spark/mllib/util/MLlibTestSparkContext.scala
----------------------------------------------------------------------
diff --git 
a/mllib/src/test/scala/org/apache/spark/mllib/util/MLlibTestSparkContext.scala 
b/mllib/src/test/scala/org/apache/spark/mllib/util/MLlibTestSparkContext.scala
index 998ee48..3781395 100644
--- 
a/mllib/src/test/scala/org/apache/spark/mllib/util/MLlibTestSparkContext.scala
+++ 
b/mllib/src/test/scala/org/apache/spark/mllib/util/MLlibTestSparkContext.scala
@@ -34,6 +34,7 @@ trait MLlibTestSparkContext extends BeforeAndAfterAll { self: 
Suite =>
     sc = new SparkContext(conf)
     SQLContext.clearActive()
     sqlContext = new SQLContext(sc)
+    SQLContext.setActive(sqlContext)
   }
 
   override def afterAll() {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to