动态 BigQuery 的侧输入 schemas/tables

Side Inputs for dynamic BigQuery schemas/tables

我想写一个 PCollection 到多个 BigQuery 表,根据 PCollection 不同架构的内容,不同表的内容其中通过侧面输入到达。

我在 DynamicDestinations 的文档中注意到了这一点:

An instance of DynamicDestinations can also use side inputs using sideInput(PCollectionView). The side inputs must be present in getSideInputs(). Side inputs are accessed in the global window, so they must be globally windowed.

如何使用 Apache Beam BigQueryIO v2.0.0 实际实现这一点 API?

假设你有像

这样的辅助输入
// Must be globally windowed to work with BigQueryIO
PCollectionView<MyAuxData> myView = ...

然后您可以像这样在 DynamicDestinations 中访问它:

new DynamicDestinations<MyElement, MyDestination>() {

  @Override
  protected List<PCollectionView<?>> getSideInputs() {
    return ImmutableLIst.of(myView);
  }

  @Override
  public TableSchema getSchema(MyDestination dest) {
    MyAuxData = sideInput(myView);
    ...
  }

  ...
}

等等。