[英]1 topic maps to two different db table Kafka Sink Connector
I am currently having trouble mapping my Kafka topic: st_record to two separate database table: 1) gt_school.strecord_1week 2) gt_school.strecord_1semester.我目前无法将我的 Kafka 主题:st_record 映射到两个单独的数据库表:1) gt_school.strecord_1week 2) gt_school.strecord_1semester。 My Kafka sink configuration is
我的 Kafka 接收器配置是
"tasks.max": "1",
"connector.class": "io.confluent.connect.jdbc.JdbcSinkConnector",
"connection.url": " "'"$URL"'",
"topics":"st_record",
"table.name.format": "gt_school.strecord_1week, gt_school.strecord_1semester",
"table.whitelist": "gt_school.strecord_1week, gt_school.strecord_1semester",
"transforms":"route",
"transforms.route.type":"org.apache.kafka.connect.transforms.RegexRouter,
"transforms.route.regex":"st_record",
"transforms.route.replacement":"gt_school.strecord_1week, gt_school.strecord_1semester"
I tried table.name.format, table.whitelist, and transform route however everytime I received the following error that both tables are unfound我尝试了 table.name.format、table.whitelist 和 transform route,但是每次我收到以下错误,两个表都找不到
io.confluent.connect.jdbc.sink.TableAlterOrCreateException: Table "gt_school"."strecord_1week, gt_school"."strecord_1semester" is missing and auto-creation is disabled"
Which is true, it should return in this format, "gt_school.strecord_1week, gt_school.strecord_1semester".这是真的,它应该以这种格式返回,“gt_school.strecord_1week,gt_school.strecord_1semester”。 Does anyone know what field it should map the two tables to from 1 topic name.
有谁知道map这两个表应该从1个主题名称的哪个字段。 Am I suppose to use table.name.format.
我应该使用 table.name.format 吗? I know that in default the topic and table name are suppose to be the same however I route it and still errors
我知道默认情况下主题和表名应该是相同的但是我路由它并且仍然出错
The error only says one table isn't found.该错误仅表示未找到一张表。 Not two.
不是两个。 The comma is within quotes... JDBC sink only writes to one table, per topic.
逗号在引号内... JDBC sink 每个主题只写入一个表。 Plus, tables cannot contain commas, as far as I know.
另外,据我所知,表格不能包含逗号。
RegexRouter doesn't split your topic into two. RegexRouter 不会将您的主题一分为二。 It only renames the topic to a static string.
它只是将主题重命名为 static 字符串。
If you want to write to two distinct tables, create two separate connectors with如果要写入两个不同的表,请创建两个单独的连接器
"topics":"st_record",
...
"transforms":"route",
"transforms.route.type":"org.apache.kafka.connect.transforms.RegexRouter",
"transforms.route.regex":".*",
"transforms.route.replacement":"$0_1week"
"topics":"st_record",
...
"transforms":"route",
"transforms.route.type":"org.apache.kafka.connect.transforms.RegexRouter",
"transforms.route.regex":".*",
"transforms.route.replacement":"$0_1semester"
However, this will obviously duplicate data in the database, so I'd recommend creating one table with data from the topic, then two VIEWs instead to do different queries of weeks/semesters但是,这显然会重复数据库中的数据,因此我建议使用主题中的数据创建一个表,然后创建两个视图来执行周/学期的不同查询
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.