I have a set of SQL rules which I need to apply on a streaming dataframe inside foreachBatch(). After applying those rules, the resultant/filtered dataframe should be written to multiple destinations like "delta" and "cosmos DB".
Below is what I have tried:
Using that static dataframe coming from forEachBatch() method, I am trying to create a temp view as below.
df.writeStream
.format("delta")
.foreachBatch(writeToDelta _)
.outputMode("update")
.start()
def upsertToDelta(microBatchOutputDF: DataFrame, batchId: Long) {
microBatchOutputDF.createOrReplaceTempView("testTable")
}
But while running the code, its showing as table or view 'testTable' not found.
Is it possible to create a temp table/view using static dataframe in spark structured streaming ?
Or how can I write to multiple sinks?