Tudor-Alexandru Voicu created KAFKA-8867: --------------------------------------------
Summary: Kafka Connect JDBC fails to create PostgreSQL table with default boolean value Key: KAFKA-8867 URL: https://issues.apache.org/jira/browse/KAFKA-8867 Project: Kafka Issue Type: Bug Components: KafkaConnect Affects Versions: 2.3.0 Reporter: Tudor-Alexandru Voicu The `CREATE TABLE ..` statement generated for sink connectors when configured with `auto.table.create=true` generates field declarations that do not conform to allowed PostgreSQL syntax when considering fields of type boolean with default values: Example of source message values Avro schema for input topic: {code:java} { "namespace": "com.test.avro.schema.v1", "type": "record", "name": "SomeEvent", "fields": [ { "name": "boolean_field", "type": "boolean", "default": false } ] } {code} The connector task fails with: {code:java} ERROR WorkerSinkTask{id=test-events-sink-0} RetriableException from SinkTask: (org.apache.kafka.connect.runtime.WorkerSinkTask:551) org.apache.kafka.connect.errors.RetriableException: java.sql.SQLException: org.postgresql.util.PSQLException: ERROR: column "boolean_field" is of type boolean but default expression is of type integer Hint: You will need to rewrite or cast the expression. at io.confluent.connect.jdbc.sink.JdbcSinkTask.put(JdbcSinkTask.java:93) at org.apache.kafka.connect.runtime.WorkerSinkTask.deliverMessages(WorkerSinkTask.java:538) at org.apache.kafka.connect.runtime.WorkerSinkTask.poll(WorkerSinkTask.java:321) at org.apache.kafka.connect.runtime.WorkerSinkTask.iteration(WorkerSinkTask.java:224) at org.apache.kafka.connect.runtime.WorkerSinkTask.execute(WorkerSinkTask.java:192) at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:175) at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:219) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748){code} The generated SQL statement is: {code:java} CREATE TABLE "test_data" ("boolean_field" BOOLEAN DEFAULT 0){code} -- This message was sent by Atlassian Jira (v8.3.2#803003)