A Dataflow DoFn fails on malformed input and you must reliably capture and reprocess bad records. What is the correct design change?
Choose an answer
Tap an option to check your answer.
Correct answer: Add a try…catch block to your DoFn that transforms the data, use a sideOutput to create a PCollection that can be stored to Pub/Sub later..
Why this is the answer
The correct approach is to use a try...catch block within your DoFn to gracefully handle malformed records. When an error occurs, the catch block should direct the erroneous record to a sideOutput. This creates a separate PCollection containing all bad records, which can then be written to a persistent store like Pub/Sub for later analysis or reprocessing. Filtering to skip errors (option 1) is not reliable as it discards data without capturing it for review. Extracting from logs (options 1 and 2) is inefficient and unreliable for programmatic reprocessing, as logs are primarily for monitoring, not data capture. Writing directly to Pub/Sub from within the DoFn (option 3) is generally discouraged in Dataflow as it can lead to performance issues and makes the pipeline less robust due to direct I/O operations from within a processing step. Side outputs are the idiomatic Dataflow way to handle divergent data paths.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed