我正在尝试编写spark scala应用程序代码的测试用例。所以我打算为此目的使用SharedSparkSession
。
我见过其他框架,如com.holdenkarau,但我正在寻找任何其他替代方案,特别是使用SharedSparkSeesion
。
所以我尝试在网上使用这个SharedSparkSession
查找示例,但我无法这样做。
如果您有任何示例,请发布。
Spark自己的测试框架可以在Scala中使用,SparkSession存在于那里。必须包含一些依赖项,对于下面的Maven,可以转换为Sbt。 ScalaTest示例:https://apache.googlesource.com/spark/+/master/sql/core/src/test/scala/org/apache/spark/sql/ColumnExpressionSuite.scala
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_${scala.suffix}</artifactId>
<version>${spark.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_${scala.suffix}</artifactId>
<version>${spark.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-catalyst_${scala.suffix}</artifactId>
<version>${spark.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>