title: Why does spark.sql MERGE INTO not work with streaming sources?
body: <p>I'm trying to do the below execution in Spark 3.1.2 / Scala 2.12:</p>
  <pre><code>streamDF.createOrReplaceTempView(&quot;tempStream&quot;)
  val query = spark.sql(
    s&quot;&quot;&quot;
       |MERGE INTO catalog.db.tablename t
       |USING tempStream s
       |ON t.ID = s.ID
       | WHEN MATCHED THEN UPDATE SET *
       | WHEN NOT MATCHED THEN INSERT *
       |&quot;&quot;&quot;.stripMargin
  )
  query
    .writeStream
    .format(&quot;console&quot;)
    .outputMode(OutputMode.Update)
    .start
    .awaitTermination
  </code></pre>
  <p>But I'm getting this exception:</p>
  <p><em><strong>Queries with streaming sources must be executed with writeStream.start()</strong></em></p>
  <p>However, the below execution works well:</p>
  <pre><code>streamDF.createOrReplaceTempView(&quot;tempStream&quot;)
  val query = spark.sql(
    s&quot;&quot;&quot;
       |SELECT COUNT(*) FROM tempStream
       |&quot;&quot;&quot;.stripMargin
  )
  query
    .writeStream
    .format(&quot;console&quot;)
    .outputMode(OutputMode.Update)
    .start
    .awaitTermination
  </code></pre>
  <p>Can someone please explain why is this happening? Is there some alternative for MERGE INTO in this case?</p>