1
我在Spark-shell中試過了下面的代碼,它工作正常。Spark Dataframes,WithColumn
val df2 = df3.withColumn("Escore", when($"col2" === $"col3",10).otherwise(0))orderBy(asc("col2"),desc("Escore"),desc("col5"))
但是當我在IntelliJ的Scala中嘗試相同的命令與SBT時,我面臨着下面的錯誤。
在斯卡拉IDE:
val df2: DataFrame = df3.withColumn("Escore": String,when($"col2" === $"col3",10).otherwise(0))orderBy(asc("col2"),desc("Escore"),desc("col5"))
錯誤:無法解析符號 「何時」。
任何人都可以提供一個示例代碼或語法如何在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"
謝謝阿卡什!這效果很好 – Falcom
太好了。不要忘記接受答案 –