Spark – Error “A master URL must be set in your configuration” when submitting an app

The TLDR: .config(“spark.master”, “local”) a list of the options for spark.master in spark 2.2.1 I ended up on this page after trying to run a simple Spark SQL java program in local mode. To do this, I found that I could set spark.master using: SparkSession spark = SparkSession .builder() .appName(“Java Spark SQL basic example”) .config(“spark.master”, … Read more

How to compile and execute scala code at run-time in Scala3?

Scala 2 version of this answer is here: How can I run generated code during script runtime? In Scala 3: For example you can use Li Haoyi‘s Ammonite ammonite.Main(verboseOutput = false).runCode(“””println(“Hello, World!”)”””) // Hello, World! build.sbt scalaVersion := “3.1.3” libraryDependencies += “com.lihaoyi” % “ammonite” % “2.5.4-22-4a9e6989” cross CrossVersion.full excludeDependencies ++= Seq( ExclusionRule(“com.lihaoyi”, “sourcecode_2.13”), ExclusionRule(“com.lihaoyi”, “fansi_2.13”), … Read more

Run a scala code jar appear NoSuchMethodError:scala.Predef$.refArrayOps

Most probably you’re compiling your code locally with Scala 2.12 but at the server it’s running with Scala 2.13 or 2.11. Try to recompile your code with the version of Scala at the server. Scala 2.11, 2.12, 2.13 are binary incompatible. The signature of refArrayOps is different (in binary incompatible way) in Scala 2.13 def … Read more

How to create a Dataset of Maps?

It is not covered in 2.2, but can be easily addressed. You can add required Encoder using ExpressionEncoder, either explicitly: import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder import org.apache.spark.sql.Encoder spark .createDataset(Seq(Map(1 -> 2)))(ExpressionEncoder(): Encoder[Map[Int, Int]]) or implicitly: implicit def mapIntIntEncoder: Encoder[Map[Int, Int]] = ExpressionEncoder() spark.createDataset(Seq(Map(1 -> 2)))

Scalaz Bind[Seq] typeclass

The collections library does backflips to accommodate subtyping: when you use map on a specific collection type (list, map, etc.), you’ll (usually) get the same type back. It manages this through the use of an extremely complex inheritance hierarchy together with type classes like CanBuildFrom. It gets the job done (at least arguably), but the … Read more