将 google 数据流管道的结果写入多个接收器

Writing results of google dataflow pipeline into mulitple sinks

我想将 Google 数据流管道结果写入多个接收器。

例如,我想使用 TextIO 将结果写入 Google Cloud Storage,并将结果作为 table 写入 BigQuery。我该怎么做?

Cloud Dataflow 管道的结构是一个 DAG(有向无环图),允许对同一个 PCollection 应用多个转换 - 写入转换也不例外。您可以将多个写入转换应用于结果的 PCollection,例如:

PCollection<Foo> results = p.apply(TextIO.Read.named("ReadFromGCS").from("gs://..."))
                         .apply(...the rest of your pipeline...);
results.apply(TextIO.Write.named("WriteToGCS").to("gs://..."));
results.apply(BigQueryIO.Write.named("WriteToBigQuery").to(...)...);