Java Apache Beam 中的 PcollectionView 阶段数据不流动
从 Bigquery 读取数据后,我必须将数据作为侧输入发送到下一级。所以下面是我遵循的步骤 -
- Read BQ
- Convert PCollection to PCollection
> - 将 Pcollection 转换为 PcollectionView (从下一步开始,仅接受 PcollectionView 作为侧面输入)
但数据不会流向步骤 3。因此,我无法将数据发送到我们的侧面输入将要去的下一个级别。
以下是数据流 -
下面是 Java 代码片段 -
PCollection<TableRow> bq_row = pipeline.apply(
"Read from BigQuery query",
BigQueryIO.readTableRows().withoutValidation().withTemplateCompatibility().fromQuery(query).usingStandardSql());
PCollection<KV<String, TableRow>> rowsKeyedByUser = bq_row
.apply(WithKeys.of(new SerializableFunction<TableRow, String>() {
@Override
public String apply(TableRow row) {
return (String) row.get("asset_id");
}
}));
PCollectionView<Map<String, TableRow>> bq_row1 = rowsKeyedByUser.apply(
"viewTags", View.<String, TableRow>asMap());
请让我们知道,我这边有什么遗漏的吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
视图操作实际上没有 PCollection 输出,它们只是用于连接侧面输入。您是否确认相关侧面输入没有获取任何数据?
如果这是一个流管道,您是否正确设置了窗口 ?如果不是,则必须在使用 DoFn 发出任何内容之前完整计算侧面输入。
特别是侧边输入在水印通过末尾之前不可用 (也就是我们知道窗口拥有它所拥有的一切)。对于全局窗口来说,这基本上是时间的终结。如果需要访问之前窗口的值,可以使用 触发器关闭。
View operations don't really have PCollection outputs, they're just used to wire up side inputs. Have you confirmed that the side input in question is not getting any data?
If this is a streaming pipeline, do you have your windowing set up correctly? If not the side input must be computed in its entirety before the DoFn consuming it will emit anything.
In particular side inputs are not available until the watermark passes the end of the corresponding window (aka we know the window has everything it will have). For the global window, that is essentially the end of time. Triggers can be used if one needs to access values of a window before it closes.