Spark - “sbt 包"- “value $ 不是 StringContext 的成员";- 缺少 Scala 插件? [英] Spark - "sbt package" - "value $ is not a member of StringContext" - Missing Scala plugin?

查看:29
本文介绍了Spark - “sbt 包"- “value $ 不是 StringContext 的成员";- 缺少 Scala 插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从命令行为小型 Spark Scala 应用程序运行sbt 包"时,我在以下代码行中收到值 $ 不是 StringContext 的成员"编译错误:

When running "sbt package" from the command line for a small Spark Scala application, I'm getting the "value $ is not a member of StringContext" compilation error on the following line of code:

val joined = ordered.join(empLogins, $"login" === $"username", "inner")
  .orderBy($"count".desc)
  .select("login", "count")

Intellij 13.1 给了我同样的错误信息.在 Eclipse 4.4.2 中编译相同的 .scala 源代码没有任何问题.并且它在命令行中的单独 maven 项目中与 maven 配合良好.

Intellij 13.1 is giving me the same error message. The same .scala source code gets compiled without any issue in Eclipse 4.4.2. And also it works well with maven in a separate maven project from the command line.

看起来 sbt 无法识别 $ 符号,因为我的项目/plugins.sbt 文件中缺少某些插件或 build.sbt 文件中的某些设置.

It looks like sbt doesn't recognize the $ sign because I'm missing some plugin in my project/plugins.sbt file or some setting in my build.sbt file.

您熟悉这个问题吗?任何指针将不胜感激.如果需要,我可以提供 build.sbt 和/或 project/plugins.sbt.

Are you familiar with this issue? Any pointers will be appreciated. I can provide build.sbt and/or project/plugins.sbt if needed be.

推荐答案

您需要确保import sqlContext.implicits._

这让你implicit class StringToColumn extends AnyRef

评论为:

将 $"col name" 转换为列.

Converts $"col name" into an Column.

这篇关于Spark - “sbt 包"- “value $ 不是 StringContext 的成员";- 缺少 Scala 插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆