Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spark - "sbt package" - "value $ is not a member of StringContext" - Missing Scala plugin?

Tags:

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 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.

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.

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

like image 668
MiguelPeralvo Avatar asked May 25 '15 20:05

MiguelPeralvo


1 Answers

You need to make sure you import sqlContext.implicits._

This gets you implicit class StringToColumn extends AnyRef

Which is commented as:

Converts $"col name" into an Column.

like image 108
Justin Pihony Avatar answered Nov 18 '22 05:11

Justin Pihony