no configuration setting found for key akka

The problem is when using sbt:assembly the default merge strategy excludes all the reference.conf files as per If multiple files share the same relative path (e.g. a resource named application.conf in multiple dependency JARs), the default strategy is to verify that all candidates have the same contents and error out otherwise. The solution is to … Read more

How to suppress Spark logging in unit tests?

Add the following code into the log4j.properties file inside the src/test/resources dir, create the file/dir if not exist # Change this to set Spark log level log4j.logger.org.apache.spark=WARN # Silence akka remoting log4j.logger.Remoting=WARN # Ignore messages below warning level from Jetty, because it’s a bit verbose log4j.logger.org.eclipse.jetty=WARN When I run my unit tests (I’m using JUnit … Read more

How to pattern match on generic type in Scala?

Maybe this will help def matchContainer[A: Manifest](c: Container[A]) = c match { case c: Container[String] if manifest <:< manifest[String] => println(c.value.toUpperCase) case c: Container[Double] if manifest <:< manifest[Double] => println(math.sqrt(c.value)) case c: Container[_] => println(“other”) } Edit: As Impredicative pointed out, Manifest is deprecated. Instead you could do the following: import reflect.runtime.universe._ def matchContainer[A: TypeTag](c: … Read more

What does “:+” mean in Scala

On Scala Collections there is usually :+ and +:. Both add an element to the collection. :+ appends +: prepends. A good reminder is, : is where the Collection goes. There is as well colA ++: colB to concat collections, where the : side collection determines the resulting type. If a :++ exists, it is … Read more

Scala Option – Getting rid of if (opt.isDefined) {}

Maybe something like this: somethingReturningAnOpt match { case Some(actualThingIWant) => doSomethingWith(actualThingIWant) case None => } or as pst suggests: somethingReturningAnOpt.foreach { actualThingIWant => doSomethingWith(actualThingIWant) } // or… for (actualThingIWant <- somethingReturningAnOpt) { doSomethingWith(actualThingIWant) }

How to save a DataFrame as compressed (gzipped) CSV?

This code works for Spark 2.1, where .codec is not available. df.write .format(“com.databricks.spark.csv”) .option(“codec”, “org.apache.hadoop.io.compress.GzipCodec”) .save(my_directory) For Spark 2.2, you can use the df.write.csv(…,codec=”gzip”) option described here: https://spark.apache.org/docs/latest/api/python/pyspark.sql.html?highlight=codec

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)