How do I supply an implicit value for an akka.stream.Materializer when sending a FakeRequest?

I’m trying to make sense of the error(s) I’m seeing below, and to learn how to fix it. could not find implicit value for parameter materializer: akka.Stream.Materializer val fut: Future[Result] = action.apply(fakeRequest).run ^ not enough arguments for method run (implicit materializer: akka.stream.Materializer)scala.concurrent.Future[play.api.mvc.Result]. Unspecified value parameter materializer. val fut: Future[Result] = action.apply(fakeRequest).run ^ Here is the … Read more

How to use from_json with Kafka connect 0.10 and Spark Structured Streaming?

I was trying to reproduce the example from [Databricks][1] and apply it to the new connector to Kafka and spark structured streaming however I cannot parse the JSON correctly using the out-of-the-box methods in Spark… note: the topic is written into Kafka in JSON format. val ds1 = spark .readStream .format(“kafka”) .option(“kafka.bootstrap.servers”, IP + “:9092”) … Read more

Better alternative to Strategy pattern in Scala?

When I’m programming in Java (or a similar language), I often employ a simple version of the Strategy pattern, using interfaces and implementation classes, to provide runtime-selectable implementations of a particular concept in my code. As a very contrived example, I might want to have the general concept of an Animal that can make a … Read more

Pattern matching on Class[_] type?

I’m trying to use Scala pattern matching on Java Class[_] (in context of using Java reflection from Scala) but I’m getting some unexpected error. The following gives “unreachable code” on the line with case jLong def foo[T](paramType: Class[_]): Unit = { val jInteger = classOf[java.lang.Integer] val jLong = classOf[java.lang.Long] paramType match { case jInteger => … Read more

an expression of type Null is ineligible for implicit conversion

When doing this: def myfunction(line: String): (Int, Option[DateTime], Option[Int]) = { // do some stuff (5, Option(null), Option(null)) } I get the following: an expression of type Null is ineligible for implicit conversion I’m not sure how to fix it. Answer Option(null) has a lower bound of Option[Null], where Null is the bottom-type of all … Read more

How to convert a case-class-based RDD into a DataFrame?

The Spark documentation shows how to create a DataFrame from an RDD, using Scala case classes to infer a schema. I am trying to reproduce this concept using sqlContext.createDataFrame(RDD, CaseClass), but my DataFrame ends up empty. Here’s my Scala code: // sc is the SparkContext, while sqlContext is the SQLContext. // Define the case class … Read more