在小型Spark Scala应用程序的命令行中运行“sbt程序包”时,在以下代码行上出现“value $ is not StringContext的成员”编译错误:
val joined = ordered.join(empLogins, $"login" === $"username", "inner")
.orderBy($"count".desc)
.select("login", "count")
Intellij 13.1给我同样的错误消息。相同的.scala源代码在Eclipse 4.4.2中被编译而没有任何问题。而且它与命令行中单独的maven项目中的maven一起使用也很好。
看起来sbt无法识别$符号,因为我缺少project / plugins.sbt文件中的某些插件或build.sbt文件中的某些设置。
您是否熟悉此问题?任何指针将不胜感激。如果需要,我可以提供build.sbt和/或project / plugins.sbt。
最佳答案
您需要确保自己 import sqlContext.implicits._
这让你implicit class StringToColumn extends AnyRef
注释为: