onQueryTerminated (StreamingQueryListener)

Called when a query is stopped, with or without error.

Syntax

onQueryTerminated(event)

Parameters

Parameter Type Description
event QueryTerminatedEvent The event object containing information about the terminated query.

Returns

None

Examples

from pyspark.sql.streaming import StreamingQueryListener

class MyListener(StreamingQueryListener):
    def onQueryStarted(self, event):
        pass

    def onQueryProgress(self, event):
        pass

    def onQueryIdle(self, event):
        pass

    def onQueryTerminated(self, event):
        print(f"Query terminated: {event.id}")

spark.streams.addListener(MyListener())