【发布时间】:2017-02-27 13:00:03
【问题描述】:
我在 Spark-shell 中尝试了以下代码,它运行良好。
val df2 = df3.withColumn("Escore", when($"col2" === $"col3",10).otherwise(0))orderBy(asc("col2"),desc("Escore"),desc("col5"))
但是当我在 IntelliJ 的 Scala 中使用 SBT 尝试相同的命令时,我遇到了以下错误。
在 Scala IDE 中:
val df2: DataFrame = df3.withColumn("Escore": String,when($"col2" === $"col3",10).otherwise(0))orderBy(asc("col2"),desc("Escore"),desc("col5"))
错误:无法解析符号“WHEN”。
谁能提供如何在 IntelliJ Scala 中编写 withColumn 数据帧的示例代码或语法。
我的 SBT 是:
name := "SparkSqlExample"
version := "1.0"
scalaVersion := "2.11.5"
libraryDependencies += "org.apache.spark" %% "spark-core" % "1.5.1"
libraryDependencies += "org.apache.spark" %% "spark-sql" % "1.5.1"
【问题讨论】:
标签: scala intellij-idea spark-dataframe