Flink CDC系列之:学习理解核心概念——Route

Route

Route 指定匹配一串 source-table 到 sink-table 的规则,最典型的场景是分库分表合并,将多个上游 source 表路由到同一张 sink 表。

参数

要描述路线,需要以下内容:

参数含义可选/必需
source-table源表id,支持正则表达式必须
sink-table接收表id,支持符号替换必须
replace-symbol接收表中用于模式替换的特殊符号,将被原始表名替换可选
description路由规则描述(提供默认值)可选

示例

将一个Data Source表路由到一个Data Sink表

假设将数据库mydb中的表web_order同步到Doris的一张表ods_web_order,我们可以用这个yaml文件来定义这个路由:

route:
  - source-table: mydb.web_order
    sink-table: mydb.ods_web_order
    description: sync table to one destination table with given prefix ods_

将多个数据源表路由到一个数据接收器表

另外,如果要将数据库 mydb 中的分片表同步到 Doris 的一张表 ods_web_order 中,我们可以用这个 yaml 文件来定义这条路由:

route:
  - source-table: mydb\.*
    sink-table: mydb.ods_web_order
    description: sync sharding tables to one destination table

通过组合路线规则实现复杂路线

另外,如果要指定多种不同的映射规则,我们可以用这个yaml文件来定义这个路由:

route:
  - source-table: mydb.orders
    sink-table: ods_db.ods_orders
    description: sync orders table to orders
  - source-table: mydb.shipments
    sink-table: ods_db.ods_shipments
    description: sync shipments table to ods_shipments
  - source-table: mydb.products
    sink-table: ods_db.ods_products
    description: sync products table to ods_products

路由规则中的模式替换

如果您想要路由源表并将其重命名为具有特定模式的接收表,则可以使用 replace-symbol 来类似于源表名称,如下所示:

route:
  - source-table: source_db.\.*
    sink-table: sink_db.<>
    replace-symbol: <>
    description: route all tables in source_db to sink_db

然后,所有表(包括 source_db.XXX)都将被轻松路由到 sink_db.XXX。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

快乐骑行^_^

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值