Scala 配置单元上下文中声明的变量在外部不可见

Scala 配置单元上下文中声明的变量在外部不可见,scala,apache-spark,Scala,Apache Spark,下面的问题只发生在eclipse中,而不是spark shell中 val dt=hc.sql(s"select max(filedt) as audit_dt,cast('$file_dt' as date) as curr_dt from cortex_dev.audit where filename='XPO Click'") if (dt.filter($"audit_dt" > $"curr_dt").count == 0) {...} 在这里,e

下面的问题只发生在eclipse中,而不是spark shell中

val dt=hc.sql(s"select max(filedt) as audit_dt,cast('$file_dt' as date) as curr_dt from cortex_dev.audit where filename='XPO Click'")
       if (dt.filter($"audit_dt" > $"curr_dt").count == 0) 
       {...}
在这里,eclipse抱怨$“audit_dt”和$“curr_dt”说

请告诉我如何解决这个问题。

我知道了

我必须在声明“val hc”后添加此项-

val hc = new HiveContext(sc)
import hc.implicits._
val hc = new HiveContext(sc)
import hc.implicits._