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

前端 未结 3 2085
情话喂你
情话喂你 2021-02-12 14:16

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 fo

3条回答
  •  攒了一身酷
    2021-02-12 14:42

    In Spark 2.0+

    $-notation for columns can be used by importing implicit on SparkSession object (spark)

    val spark = org.apache.spark.sql.SparkSession.builder
            .master("local")
            .appName("App name")
            .getOrCreate;
    
    import spark.implicits._
    

    then your code with $ notation

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

提交回复
热议问题