{"action":"opened","issue":{"url":"https://api.github.com/repos/confluentinc/kafka-connect-jdbc/issues/165","repository_url":"https://api.github.com/repos/confluentinc/kafka-connect-jdbc","labels_url":"https://api.github.com/repos/confluentinc/kafka-connect-jdbc/issues/165/labels{/name}","comments_url":"https://api.github.com/repos/confluentinc/kafka-connect-jdbc/issues/165/comments","events_url":"https://api.github.com/repos/confluentinc/kafka-connect-jdbc/issues/165/events","html_url":"https://github.com/confluentinc/kafka-connect-jdbc/issues/165","id":189016766,"number":165,"title":"Unsigned numeric fields not correctly supported","user":{"login":"andybryant","id":803795,"avatar_url":"https://avatars.githubusercontent.com/u/803795?v=3","gravatar_id":"","url":"https://api.github.com/users/andybryant","html_url":"https://github.com/andybryant","followers_url":"https://api.github.com/users/andybryant/followers","following_url":"https://api.github.com/users/andybryant/following{/other_user}","gists_url":"https://api.github.com/users/andybryant/gists{/gist_id}","starred_url":"https://api.github.com/users/andybryant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andybryant/subscriptions","organizations_url":"https://api.github.com/users/andybryant/orgs","repos_url":"https://api.github.com/users/andybryant/repos","events_url":"https://api.github.com/users/andybryant/events{/privacy}","received_events_url":"https://api.github.com/users/andybryant/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-14T02:39:44Z","updated_at":"2016-11-14T02:39:44Z","closed_at":null,"body":"I am reading from a MariaDB database with an unsigned INT field to store IP address.\r\n`DataConverter.java` ignores whether the field is signed or not when generating the Kafka Connect Schema, always converting `Types.INTEGER` into `Schema.OPTIONAL_INT32_SCHEMA` or `Schema.INT32_SCHEMA`.\r\n\r\nWhen reading from the database this results in a `resultSet.getInt` call which will fail when the value is greater than `Integer.MAX_VALUE`. Here's an example of this happening...\r\n\r\n```\r\n[2016-11-11 15:58:49,574] WARN Ignoring record due to SQL error: (io.confluent.connect.jdbc.JdbcSourceTask:73)\r\njava.sql.SQLException: Out of range value for column 'customers_ip_number' : value 3707109316 is not in class java.lang.Integer range\r\n\tat org.mariadb.jdbc.internal.queryresults.resultset.MariaSelectResultSet.rangeCheck(MariaSelectResultSet.java:3005)\r\n\tat org.mariadb.jdbc.internal.queryresults.resultset.MariaSelectResultSet.getInt(MariaSelectResultSet.java:1016)\r\n\tat org.mariadb.jdbc.internal.queryresults.resultset.MariaSelectResultSet.getInt(MariaSelectResultSet.java:956)\r\n\tat io.confluent.connect.jdbc.DataConverter.convertFieldValue(DataConverter.java:299)\r\n\tat io.confluent.connect.jdbc.DataConverter.convertRecord(DataConverter.java:68)\r\n\tat io.confluent.connect.jdbc.TimestampIncrementingTableQuerier.extractRecord(TimestampIncrementingTableQuerier.java:179)\r\n\tat io.confluent.connect.jdbc.JdbcSourceTask.poll(JdbcSourceTask.java:217)\r\n\tat org.apache.kafka.connect.runtime.WorkerSourceTask.execute(WorkerSourceTask.java:155)\r\n\tat org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:140)\r\n\tat org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:175)\r\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\r\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\n```\r\n\r\nThe Kafka Connect Schema spec should either support unsigned types like `INT32_UNSIGNED_SCHEMA` or kafka-connect-jdbc could check the signed flag when reading the DB schema and conservatively assign a schema that will always be able to read the data.\r\n\r\nThe first approach seems cleaner, but would involve a change on the Kafka Connect API as well as all connectors.\r\n\r\nNote TINYINT is also currently not handled correctly as according to this page, these are always unsigned and so should be read as a short not a byte.\r\nhttps://www.cis.upenn.edu/~bcpierce/courses/629/jdkdocs/guide/jdbc/getstart/mapping.doc.htm\r\n\r\nFinally unsigned BIGINT values should be read in as BigIntegers not Longs.\r\n\r\nIf the second approach is preferred, I can make a PR.\r\n"}}
{"actor":{"display_login":"andybryant"}}