动态路由到 Apache Beam 中的 IO 接收器

Dynamic routing to IO sink in Apache Beam

查看 ClickHouseIO 的示例 Apache Beam 输出的名称 table 是硬编码的:

 pipeline
   .apply(...)
   .apply(
     ClickHouseIO.<POJO>write("jdbc:clickhouse:localhost:8123/default", "my_table"));

有没有办法根据记录的内容将记录动态路由到 table?

即如果记录包含 table=1,它被路由到 my_table_1table=2my_table_2

不幸的是,ClickHouseIO 仍然是 in development does not support this. The BigQueryIO does support Dynamic Destinations,因此可以使用 Beam。

当前 ClickHouseIO 的局限在于转换数据以匹配目标 table 模式。作为解决方法,如果您的目标 table 在管道创建时已知,您可以为每个 table 创建一个 ClickHouseIO,然后使用数据路由到正确的 IO 实例。

您可能想为此在 Beam bug tracker 中提交功能请求。