2016-07-11 110 views
0

当路过sqlContext我有以下的测试案例:测试方法

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

回答

1

implicit在前面的val sqlc

implicit val sqlc = new SQLContext(sc)