I'm using Apache Beam to set up a pipeline consisting of 2 main steps:
- transform the data using a Beam Transform
- load the transformed data to BigQuery
The pipeline setup looks like this:
myPCollection = (org.apache.beam.sdk.values.PCollection<myCollectionObjectType>)myInputPCollection
.apply("do a parallel transform"),
ParDo.of(new MyTransformClassName.MyTransformFn()));
myPCollection
.apply("Load BigQuery data for PCollection",
BigQueryIO.<myCollectionObjectType>write()
.to(new MyDataLoadClass.MyFactTableDestination(myDestination))
.withFormatFunction(new MyDataLoadClass.MySerializationFn())
I've looked at this question:
Apache Beam: Skipping steps in an already-constructed pipeline
which suggests that I may be able to somehow dynamically change which output I can pass data to, following the parallel transform in step 1.
How do I do this? I don't know how to choose whether or not to pass myPCollection
from step 1 to step 2. I need to skip step 2 if the object in myPCollection
from step 1 is null
.