In my Apache Beam pipeline I have collection that may be empty (it contains errors from processing, there may be no errors).
I create file errors.csv with those erroneous items. I would like to skip creating that file if there are no errors. But currently Apache Beam creates file (with just header line) even when input PCollection with errors is empty.
my code
TextIO.Write errorsWrite= TextIO.write()
.withHeader(..)
.to(..)
PCollection<ErrorItems> errors=...
errors.apply("write errors to file",errorsWrite)