Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-4342

Kafka-connect- support tinyint values

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Not A Problem
    • None
    • None
    • None
    • None

    Description

      We have been using Kafka-connect-jdbc actively for one of our projects and one of the issues that we have noticed is the way it handles the tinyint values.

      Our database is on mysql and mysql allows both signed and unsigned values to be stored. So, it can have values going upto 255 but when kafka-connect sees values beyond 128, it fails.

      Reason being, in the ConnectSchema class, the INT8 maps to a Byte which is a signed value. If we look at the jdbc docs then this is what they say about handling tinyint values:

      https://docs.oracle.com/javase/6/docs/technotes/guides/jdbc/getstart/mapping.html

      8.3.4 TINYINT
      The JDBC type TINYINT represents an 8-bit integer value between 0 and 255 that may be signed or unsigned.

      The corresponding SQL type, TINYINT, is currently supported by only a subset of the major databases. Portable code may therefore prefer to use the JDBC SMALLINT type, which is widely supported.

      The recommended Java mapping for the JDBC TINYINT type is as either a Java byte or a Java short. The 8-bit Java byte type represents a signed value from -128 to 127, so it may not always be appropriate for larger TINYINT values, whereas the 16-bit Java short will always be able to hold all TINYINT values.

      I had submitted a PR for this last week. But it failed in the jenkins build for unrelated test case. So, if someone can take a look at this or suggest something then it would be great:

      https://github.com/apache/kafka/pull/2044

      Attachments

        Activity

          People

            Unassigned Unassigned
            sagarrao Sagar Rao
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: