How to use Spark Structured Streaming with Kafka Direct Stream?
<p>I came across <a href="https://databricks.com/blog/2016/07/28/structured-streaming-in-apache-spark.html" rel="noreferrer">Structured Streaming with Spark</a>, it has an example of continuously consuming from an S3 bucket and writing processed results to a MySQL  DB.</p>

<pre><code>// Read data continuously from an S3 location
val inputDF = spark.readStream.json("s3://logs")

// Do operations using the standard DataFrame API and write to MySQL
inputDF.groupBy($"action", window($"time", "1 hour")).count()
       .writeStream.format("jdbc")
       .start("jdbc:mysql//...")
</code></pre>

<p>How can this be used with <a href="http://spark.apache.org/docs/latest/streaming-kafka-integration.html" rel="noreferrer">Spark Kafka Streaming</a>?</p>

<pre><code>val stream = KafkaUtils.createDirectStream[String, String](
  ssc,
  PreferConsistent,
  Subscribe[String, String](topics, kafkaParams)
)
</code></pre>

<p>Is there a way to combine these two examples without using <code>stream.foreachRDD(rdd =&gt; {})</code>?</p>