Analytics SDK Scala with Spark - DStream to Streaming Dataframe


I’m new to this but I’m trying to figure out how to get a Streaming DataFrame in Spark from Kafka input.

val spark = SparkSession
  .appName("Main Processor")

import spark.implicits._

val sdf = spark
  .option("kafka.bootstrap.servers", "localhost:9092")
  .option("subscribe", "enriched-good")
sdf.selectExpr("CAST(key AS STRING)", "CAST(value AS STRING)")
  .as[(String, String)]   

val events = => Event.parse(line))
  .map(event => event.toJson(true).noSpaces)

The last part makes no sense as events is a DStream.

Any idea how to achieve that ?