[英]Why it is an error on compiler but run at Spark-shell?
The command命令
println( sql( "SELECT date_format(now(),'yyyyMMdd')" ).as[String].first )
is working fine on Spark-shell (using Spark v2.2), but the line在 Spark-shell 上运行良好(使用 Spark v2.2),但是行
val databaseNow = spark.sql( "SELECT date_format(now(),'yyyyMMdd')" ).as[String].first
not compile.不编译。 I try many import variations and problem persist.
我尝试了许多导入变体,但问题仍然存在。 I try syntax variations as
df.first.toString
but it is not a solution ( [x]
is not x
).我尝试将语法变体作为
df.first.toString
,但这不是解决方案( [x]
is not x
)。
Just include the included encoders like:只需包括包含的编码器,例如:
val spark: SparkSession =
SparkSession
.builder()
.appName("test")
.getOrCreate()
import spark.implicits._
val databaseNow = spark.sql( "SELECT date_format(now(),'yyyyMMdd')" ).as[String].first
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.