import time # Stream the content of the DataFrame query = sourceStream.writeStream .queryName("count") .format("memory") .outputMode("append") .start() # Display the count of rows for _ in range(10): spark.sql("SELECT COUNT(*) AS no_of_rows FROM count").show() time.sleep(10)