Created
March 10, 2022 22:20
-
-
Save dyno/c81922d5e35a3d6c98a874bbaeee90c0 to your computer and use it in GitHub Desktop.
Revisions
-
dyno created this gist
Mar 10, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ import org.apache.spark.sql.SparkSession import org.apache.spark.{SparkConf, SparkContext} import org.scalatest.{BeforeAndAfterAll, Suite} // https://www.slideshare.net/SparkSummit/spark-summit-eu-talk-by-ted-malaska trait SharedSparkContext extends BeforeAndAfterAll { self: Suite => @transient private var _sc: SparkContext = _ def sc: SparkContext = _sc def spark: SparkSession = SparkSession.builder().config(_sc.getConf).getOrCreate() override def beforeAll() { super.beforeAll() val conf = new SparkConf().setAppName("applogs-test").setMaster("local[2]") _sc = new SparkContext(conf) } override def afterAll() { _sc.stop() super.afterAll() } }