1

是否有一个易于遵循的示例如何配置流模式 Dataflow Pipeline 以将每个窗口写入单独的 BigQuery 表(并在必要时创建一个)?

即——table_20160701、table_20160702等。

4

1 回答 1

3

示例代码:

`

PCollection<TableRow> quotes = 
  quotes.apply(Window.<TableRow>into(CalendarWindows.days(1)))
        .apply(BigQueryIO.Write
          .named("Write")
          .withSchema(schema)
          .to(new SerializableFunction<BoundedWindow, String>() {
            public String apply(BoundedWindow window) {
              // The cast below is safe because CalendarWindows.days(1) produces IntervalWindows.
              String dayString = DateTimeFormat.forPattern("yyyy_MM_dd")
                   .withZone(DateTimeZone.UTC)
                   .print(((IntervalWindow) window).start());
              return "my-project:output.output_table_" + dayString;
            }
          }));
  }

`

取自这里:

https://github.com/GoogleCloudPlatform/DataflowJavaSDK/blob/master/sdk/src/main/java/com/google/cloud/dataflow/sdk/io/BigQueryIO.java

于 2016-07-07T06:59:24.527 回答