How can we assemble an array of specific error reason codes for failed records and route them to quarantine?
array_compact() and when() combine triggered error codes into a list of specific failure reasons.
Dead-letter queue (DLQ) tables allowing upstream data providers to remediate flawed payloads.
df_errors = df.withColumn("errors", array_compact(array(when(col("id").isNull(), "ERR_NULL_ID"), when(col("amount") <= 0, "ERR_INVALID_AMOUNT"))))
df_quarantine = df_errors.filter(size(col("errors")) > 0)Practice typing production-grade PySpark code for Quarantine Routing with Error Reasons.