我有以下测试用例:
test("check foo") {
val conf = new SparkConf()
val sc = new SparkContext(conf)
val sqlc = new SQLContext(sc)
val res = foo("A", "B")
assert(true)
}
检查以下方法:
def foo(arg1: String, arg2: String) (implicit sqlContext: SQLContext) : Seq[String] = {
//some other code
}
运行测试时,我遇到以下问题:
Error:(65, 42) could not find implicit value for parameter sqlContext: org.apache.spark.sql.SQLContext
val res = foo("A", "B")
如何与SqlContext
分享我在测试方法中创建的foo
实例?
答案 0 :(得分:1)
将implicit
放在val sqlc
:
implicit val sqlc = new SQLContext(sc)