5

I have some database table with bg_ and cp_ prefix like "bg_table1", "bg_table2" and "cp_table1".There are also some other tables without any prefix such as my_table1, user_action and so forth.

I have two debezium postgreSQL connectors and trying to configure table.whitelist property by following Debezium - http://debezium.io/docs/connectors/postgresql/#connector-properties. My requirements are as follows:

  • in the first connector I want to load the tables whose names start with bg_ or cp_
  • in the second connector I want to load the rest of the tables - does not start with bg_ or cp_

I am using something like below in the connector configuration but does not work:

First Connector Config:

"table.whitelist": "public.bg_*,public.cp_*" 

Second Connector Config:

"table.whitelist": ""  Cannot figure out need your help

It would be great if someone could help me figure it out. Thanks in advance!

4

1 回答 1

9

试试这个为你的白名单:

"table.whitelist": "public\.(bg|cp)_.*"

演示

并为您的黑名单尝试此操作:

"table.whitelist": "public\.(?!(bg|cp)_)[^_]+_.*"

演示

第一个模式应该几乎适用于任何正则表达式引擎。第二种模式使用负前瞻。只有当你的正则表达式引擎支持它时它才会起作用。如果没有,那么使用您想要使用的逻辑编写模式将更加困难。

注意:在 Java 代码的上下文中,您可能需要加倍反斜杠来转义点之类的东西。也就是说,您可能必须使用以下版本,例如

"table.whitelist": "public\\.(bg|cp)_.*"
于 2018-07-15T05:57:55.953 回答