title: How to access the data from streaming query in "memory" table for subsequent batch queries?
body: <p>Given a <code>writeStream</code> call:</p>
  
  <pre><code>val outDf = (sdf.writeStream
    .outputMode(outputMode)
    .format("memory")
    .queryName("MyInMemoryTable")
    .trigger(Trigger.ProcessingTime(interval))
    .start())
  </code></pre>
  
  <p>How can I run a <code>sql</code> against the <code>MyInMemoryTable</code> e.g.</p>
  
  <pre><code>  val df = spark.sql("""select Origin,Dest,Carrier,avg(DepDelay) avgDepDelay 
                  from MyInMemoryTable group by 1,2,3""")
  </code></pre>
  
  <p>The documentation for <code>Spark Structured Streaming</code> says that batch and streaming queries can be intermixed but the above is not working: </p>
  
  <pre><code>'writeStream' can be called only on streaming Dataset/DataFrame;
  org.apache.spark.sql.AnalysisException: 'writeStream' can be called only 
     on streaming Dataset/DataFrame;
  </code></pre>
  
  <p>So how can the <code>InMemoryTable</code> be used in subsequent queries?</p>