Using Scala 2.12 with Spark 2.x

后端 未结 3 1007
一整个雨季
一整个雨季 2020-12-05 18:02

At the Spark 2.1 docs it\'s mentioned that

Spark runs on Java 7+, Python 2.6+/3.4+ and R 3.1+. For the Scala API, Spark 2.1.0 uses Scala 2.11. You wi

3条回答
  •  忘掉有多难
    2020-12-05 18:47

    Scala 2.12 is officially supported (and required) as of Spark 3. Summary:

    • Spark 2.0 - 2.3: Required Scala 2.11
    • Spark 2.4: Supported Scala 2.11 and Scala 2.12, but not really cause almost all runtimes only supported Scala 2.11.
    • Spark 3: Only Scala 2.12 is supported

    Using a Spark runtime that's compiled with one Scala version and a JAR file that's compiled with another Scala version is dangerous and causes strange bugs. For example, as noted here, using a Scala 2.11 compiled JAR on a Spark 3 cluster will cause this error: java.lang.NoSuchMethodError: scala.Predef$.refArrayOps([Ljava/lang/Object;)Lscala/collection/mutable/ArrayOps.

    Look at all the poor Spark users running into this very error.

    Make sure to look into Scala cross compilation and understand the %% operator in SBT to limit your suffering. Maintaining Scala projects is hard and minimizing your dependencies is recommended.

提交回复
热议问题