How to use the Kafka Connect JDBC to source PostgreSQL with multiple schemas that contain tables with the same name?
Asked Answered
S

0

10

I need to source data from a PostgreSQL database with ~2000 schemas. All schemas contain the same tables (it is a multi-tenant application).

The connector is configured as following:

{
  "name": "postgres-source",
  "connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
  "timestamp.column.name": "updated",
  "incrementing.column.name": "id",
  "connection.password": "********",
  "tasks.max": "1",
  "mode": "timestamp+incrementing",
  "topic.prefix": "postgres-source-",
  "connection.user": "*********",
  "poll.interval.ms": "3600000",
  "numeric.mapping": "best_fit",
  "connection.url": "jdbc:postgresql://*******:5432/*******",
  "table.whitelist": "table1",
  "value.converter": "org.apache.kafka.connect.json.JsonConverter",
  "value.converter.schemas.enable": "false",
  "key.converter": "org.apache.kafka.connect.json.JsonConverter",
  "key.converter.schemas.enable":"false"
}

With this configuration, I get this error:

"The connector uses the unqualified table name as the topic name and has detected duplicate unqualified table names. This could lead to mixed data types in the topic and downstream processing errors. To prevent such processing errors, the JDBC Source connector fails to start when it detects duplicate table name configurations"

Apparently the connector does not want to publish data from multiple tables with the same name to a single topic.

This does not matter to me, it could go to a single topic or multiple topics (one for each schema).

As an additional info, if I add:

"schema.pattern": "schema1" 

to the config, the connector works and the data from the specified schema and table is copied.

Is there a way to copy multiple schemas that contain tables with the same name?

Thank you

Scissor answered 18/4, 2019 at 17:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.