A data engineer wants to run an incremental ingestion job every six hours. They want to ensure that each run processes all available data and then shuts down the cluster to save costs. Which Trigger should be used in the Structured Streaming code?
Trigger.AvailableNow is designed for this exact use case. It processes all currently available data from the source, potentially splitting it into multiple smaller micro-batches for better performance and stability. Once all data is processed, the query terminates, allowing the cluster to be shut down automatically.
Why this answer
Trigger.AvailableNow is the modern replacement for Trigger.Once. It provides better scalability by processing all available data in multiple micro-batches if necessary, while still allowing the job to terminate once all data is processed. This is ideal for cost-effective, periodic batch-style processing of streaming data sources.
Exam trap
Candidates frequently choose Trigger.Once, failing to recognize that Trigger.AvailableNow is the modern, scalable replacement for batch-style streaming jobs.