【发布时间】:2018-01-30 16:16:36
【问题描述】:
无法在 spark-2.2.0 上使用上下文运行 run scalatest
堆栈跟踪:
异常或错误导致运行中止:org.apache.spark.sql.test.SharedSQLContext.eventually(Lorg/scalatest/concurrent/PatienceConfiguration$Timeout;Lscala/Function0;Lorg/scalatest/concurrent/AbstractPatienceConfiguration$PatienceConfig ;)Ljava/lang/Object; java.lang.NoSuchMethodError: org.apache.spark.sql.test.SharedSQLContext.eventually(Lorg/scalatest/concurrent/PatienceConfiguration$Timeout;Lscala/Function0;Lorg/scalatest/concurrent/AbstractPatienceConfiguration$PatienceConfig;)Ljava/lang/Object ; 在 org.apache.spark.sql.test.SharedSQLContext$class.afterEach(SharedSQLContext.scala:92) 在 testUtils.ScalaTestWithContext1.afterEach(ScalaTestWithContext1.scala:7) 在 org.scalatest.BeforeAndAfterEach$$anonfun$1.apply$mcV$sp(BeforeAndAfterEach.scala:234)
示例代码:
import org.apache.spark.sql.SparkSession
import testUtils.ScalaTestWithContext1
class SampLeTest extends ScalaTestWithContext1 {
override protected def spark: SparkSession = ???
test("test") {
1 == 1 shouldBe true
}
}
ScalaTestWithContext1.scala
import org.apache.spark.sql.QueryTest
import org.apache.spark.sql.test.SharedSQLContext
import org.scalatest.{BeforeAndAfterAll, Matchers}
abstract class ScalaTestWithContext extends QueryTest with SharedSQLContext with Matchers with BeforeAndAfterAll{}
build.sbt:
name := "test"
version := "1.0"
scalaVersion := "2.11.11"
parallelExecution in Test := false
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-library" % "2.11.11" % "provided",
"org.apache.spark" %% "spark-core" % "2.2.0",
"org.apache.spark" %% "spark-sql" % "2.2.0",
"org.apache.spark" %% "spark-catalyst" % "2.2.0",
"org.apache.spark" %% "spark-core" % "2.2.0" % "test" classifier
"tests",
"org.apache.spark" %% "spark-sql" % "2.2.0" % "test" classifier
"tests",
"org.apache.spark" %% "spark-catalyst" % "2.2.0" % "test" classifier
"tests",
"org.scalatest" %% "scalatest" % "3.0.1" % "test"
)
ScalaTestWithContext1 类扩展了 SharedSQLContext 和所有必需的特征。
提前致谢。
【问题讨论】:
-
稍微减少堆栈跟踪并添加一些相关代码。
-
scalatest with sharedSQLContext 适用于 spark-2.1.0,我对 spark-2.2.0 有问题
-
项目的
build.sbt是什么?
标签: scala apache-spark sbt apache-spark-sql scalatest