You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@toree.apache.org by ch...@apache.org on 2017/02/25 21:03:12 UTC
incubator-toree git commit: TOREE-376: Add implicits to the
interpreter.
Repository: incubator-toree
Updated Branches:
refs/heads/master e048b58a7 -> c996c7dd9
TOREE-376: Add implicits to the interpreter.
Project: http://git-wip-us.apache.org/repos/asf/incubator-toree/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-toree/commit/c996c7dd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-toree/tree/c996c7dd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-toree/diff/c996c7dd
Branch: refs/heads/master
Commit: c996c7dd9e78615973dda8745982f94abe7133bb
Parents: e048b58
Author: Ryan Blue <bl...@apache.org>
Authored: Fri Feb 10 10:29:31 2017 -0800
Committer: Ryan Blue <bl...@apache.org>
Committed: Tue Feb 21 14:06:55 2017 -0800
----------------------------------------------------------------------
.../interpreter/scala/ScalaInterpreter.scala | 25 ++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/c996c7dd/scala-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/scala/ScalaInterpreter.scala
----------------------------------------------------------------------
diff --git a/scala-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/scala/ScalaInterpreter.scala b/scala-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/scala/ScalaInterpreter.scala
index 5f36a1e..360476b 100644
--- a/scala-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/scala/ScalaInterpreter.scala
+++ b/scala-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/scala/ScalaInterpreter.scala
@@ -90,10 +90,11 @@ class ScalaInterpreter(private val config:Config = ConfigFactory.load) extends I
this
}
- override def postInit(): Unit = {
- bindSparkSession()
- bindSparkContext()
- }
+ override def postInit(): Unit = {
+ bindSparkSession()
+ bindSparkContext()
+ defineImplicits()
+ }
protected[scala] def buildClasspath(classLoader: ClassLoader): String = {
@@ -318,6 +319,22 @@ class ScalaInterpreter(private val config:Config = ConfigFactory.load) extends I
}
}
+ def defineImplicits(): Unit = {
+ val code =
+ """
+ |import org.apache.spark.sql.SparkSession
+ |import org.apache.spark.sql.SQLContext
+ |import org.apache.spark.sql.SQLImplicits
+ |
+ |object implicits extends SQLImplicits with Serializable {
+ | protected override def _sqlContext: SQLContext = SparkSession.builder.getOrCreate.sqlContext
+ |}
+ |
+ |import implicits._
+ """.stripMargin
+ doQuietly(interpret(code))
+ }
+
override def classLoader: ClassLoader = _runtimeClassloader
/**