使用KSQL创建Kafka源连接器时MariaDB日期字段读取失败
Let's break down what's happening here and confirm the fix you've already found, plus add context for others facing the same issue:
Root Cause Analysis
The error Kafka Connect Date type should not have any time fields set to non-zero values reveals a conversion mismatch between the MariaDB connector and Kafka Connect's logical Date type.
Kafka Connect's Date logical type strictly expects values representing days since the epoch, with no non-zero time components (hours, minutes, seconds must all be zero). It seems the MariaDB connector included with Confluent Platform 6.0.0 has a bug where it incorrectly appends non-zero time values when reading MariaDB DATE columns—even though MariaDB's DATE type doesn't store time data at all. This triggers the Avro converter to reject the record, as it violates the logical type's constraints.
Confirmed Fix
Your workaround of swapping the MariaDB connector JAR with the MySQL connector JAR is a solid solution. Since MariaDB maintains high compatibility with MySQL, the MySQL connector correctly handles DATE type conversion, ensuring only the pure date component is passed to Kafka Connect without any extraneous time values. As you saw, this resolves the error entirely and lets all records flow into the Kafka topic.
Additional Recommendations
- If you want to stick with the MariaDB connector, check for a patched version compatible with Confluent Platform 6.0.0, or consider upgrading your Confluent Platform installation to a newer release—later versions may have fixed this date conversion bug.
- As a temporary band-aid, you could try explicitly defining the
enrollment_datefield type in your connector configuration to enforce correct conversion, but this is less reliable than using the already-working MySQL connector.
内容的提问来源于stack exchange,提问作者al gh

