Skip to content

Write the failures

To write the failures to a dead letter queue, convert them to a flat format with a documented schema:

Field (Java / Python) Type Description
pipelineStep string, nullable Name of the failing step
inputElement string Input element of the failing step
originElement string, nullable Origin element, when it’s tracked
exceptionType string Class name of the exception (the original one for a non serializable exception)
exceptionMessage string, nullable Message of the exception
stackTrace string Stack trace, causes included
timestamp datetime, nullable When the failure was created

FailureTransforms.toRows() converts the failures to Beam Rows with the FailureTransforms.SCHEMA, used by BigQueryIO to create the table:

result.failures()
.apply("Failures to rows", FailureTransforms.toRows())
.apply("Write failures", BigQueryIO.<Row>write()
.to("my-project:my_dataset.failures")
.useBeamSchema()
.withCreateDisposition(BigQueryIO.Write.CreateDisposition.CREATE_IF_NEEDED)
.withWriteDisposition(BigQueryIO.Write.WriteDisposition.WRITE_APPEND));

FailureTransforms.toRow(failure) converts a single failure, e.g. in your own transform.