The answer is Checkpointing and idempotent sinks
How does structured streaming achieves end to end fault tolerance:
First, Structured Streaming uses checkpointing and write-ahead logs to record the offset range of data being processed during each trigger interval.
Next, the streaming sinks are designed to be _idempotent_—that is, multiple writes of the same data (as identified by the offset) do not result in duplicates being written to the sink.
Taken together, replayable data sources and idempotent sinks allow Structured Streaming to ensure end-to-end, exactly-once semantics under any failure condition.