Can you walk through your process for debugging a complex PySpark pipeline? For the coding portion, implement first_bad_stage(stage_outputs, required_fields). stage_outputs is an ordered array of stage objects, each containing a name and output rows; required_fields maps each stage name to required field names. Return [stage_index, row_index] for the first row that is missing a required field or contains a null value, scanning stages and rows in order, or [-1, -1] when all outputs are valid.
def first_bad_stage(stage_outputs, required_fields):