简体   繁体   English

1 个主题映射到两个不同的数据库表 Kafka Sink Connector

[英]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.

相关问题 Kafka Sink 如何将 map 字段用于具有不同主题和表模式名称的数据库 - Kafka Sink how to map fields to db with different topic and table schema name 无法使用 JDBC kafka-sink-connector 将 kafka 主题数据写入 postgres DB - Unable to write kafka topic data into postgres DB using JDBC kafka-sink-connector 融合的Kafka Sink连接器未将数据加载到Postgres表中 - Confluent Kafka Sink Connector is not loading data to Postgres table 不支持的源数据类型:从 Kafka 主题消费时 JDBC Postgres Sink Connector 中的 STRUCT 错误 - Unsupported source data type: STRUCT error in JDBC Postgres Sink Connector when consuming from Kafka topic 使用 Kafka Postgres Sink 连接器反序列化消息时出错 - Error deserializing message with Kafka Postgres Sink Connector Kafka JDBC 接收器连接器未访问正确的连接器配置 - Kafka JDBC sink connector does not access the correct connector configurations Debezium 源到 Postgres sink DB-JDBC Sink 连接器问题 - Debezium source to Postgres sink DB- JDBC Sink connector issue Kafka JDBC Sink 连接器与 PostgreSQL 12 兼容吗? - Kafka JDBC Sink Connector compatibly works with PostgreSQL 12? 无法使用 Kafka JDBC 接收器连接器将数据加载到 Postgres - Unable to load data to Postgres using Kafka JDBC Sink Connector Kafka Connect-JSON转换器-JDBC Sink连接器-列类型JSON - Kafka Connect - JSON Converter - JDBC Sink Connector - Column Type JSON
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM