onQueryStarted (StreamingQueryListener)
Called when a query is started.
Syntax
onQueryStarted(event)
Parameters
Parameter | Type | Description |
|---|---|---|
| QueryStartedEvent | The event object containing information about the started query. |
Returns
None
Notes
This method is called synchronously with DataStreamWriter.start(). That is, onQueryStarted is called on all listeners before DataStreamWriter.start() returns the corresponding StreamingQuery. Do not block this method as it will block your query.
Examples
Python
from pyspark.sql.streaming import StreamingQueryListener
class MyListener(StreamingQueryListener):
def onQueryStarted(self, event):
print(f"Query started: {event.id}")
def onQueryProgress(self, event):
pass
def onQueryIdle(self, event):
pass
def onQueryTerminated(self, event):
pass
spark.streams.addListener(MyListener())