[英]SQL Server CDC - Snapshot from specific date for Debezium Kafka
We are enabling CDC on specific tables in our MSSQL.我们正在 MSSQL 中的特定表上启用 CDC。 We are connecting to a pipeline of migrating data through
MSSQL->CDC->DEBEZIUM->KAFKA_CONNECT
我们正在通过
MSSQL->CDC->DEBEZIUM->KAFKA_CONNECT
连接到迁移数据的管道
There is a table that has more than a million rows, but we need only a few thousand rows from the table to be included in the Snapshot Created when enabling CDC.有一个表有超过一百万行,但我们只需要将表中的几千行包含在启用 CDC 时创建的快照中。 The reason why I don't want to handle it in our Kafka-Consumer is because, while I need just 1% of the data to be written to Mongo, rest 99% is gonna hit the consumer without any use.
我不想在我们的 Kafka-Consumer 中处理它的原因是,虽然我只需要将 1% 的数据写入 Mongo,但 rest 99% 将毫无用处地打击消费者。
Questions:问题:
You can use Kafka Connect Single Message Transform (SMT) .您可以使用Kafka Connect 单消息转换 (SMT) 。 More precisely, you need the
Filter
SMT:更准确地说,您需要
Filter
SMT:
The
filter.condition
is a predicate specifying JSON path that is applied to each record processed, and when this predicate successfully matches the record is either included (whenfilter.type=include
) or excluded (whenfilter.type=exclude
)filter.condition
是一个谓词,指定 JSON 路径,该路径应用于处理的每个记录,并且当此谓词成功匹配记录时,要么包括(当filter.type=include
)或排除(当filter.type=exclude
)
In your case, you can include rows that satisfy your desired condition:在您的情况下,您可以包含满足所需条件的行:
transforms=filter-records
transforms.filterExample1.type=io.confluent.connect.transforms.Filter$Value
transforms.filterExample1.filter.condition=$.value[?(@.modified_date > "1/1/2020")]
transforms.filterExample1.filter.type=include
transforms.filterExample1.missing.or.null.behavior=fail
Alternatively, you can decide which rows to exclude :或者,您可以决定要排除哪些行:
transforms=filter-records
transforms.filterExample1.type=io.confluent.connect.transforms.Filter$Value
transforms.filterExample1.filter.condition=$.value[?(@.modified_date <= "1/1/2020")]
transforms.filterExample1.filter.type=exclude
transforms.filterExample1.missing.or.null.behavior=fail
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.