是否有一个易于理解的示例如何配置流模式Dataflow Pipeline将每个窗口写入单独的BigQuery表(并在必要时创建一个)?
即。 - table_20160701,table_20160702等
答案 0 :(得分:2)
示例代码:
`
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;
}
}));
}
`
从这里采取: