Uploaded image for project: 'Debezium'
  1. Debezium
  2. DBZ-4550

PostresSQL ENUM Failing

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not a Bug
    • Critical
    • None
    • 1.8.0.Final
    • postgresql-connector
    • None
    • False
    • False
    • 1.8.0-Final
    • Hide
      1. Database: AWS Aurora PostgreSQL 10.18
      2. Creating connector on a database with several ENUM types example provided in description.
      3. The connector is failing at the initialization step itself with the ClassCastException.
      Show
      Database: AWS Aurora PostgreSQL 10.18 Creating connector on a database with several ENUM types example provided in description. The connector is failing at the initialization step itself with the ClassCastException.

    Description

      We are onboarding Debezium 1.8.0 Final postgresql connector. One of our database(s) uses a lot of ENUM Types. For e.g.

      CREATE TYPE status AS ENUM ( 'REJECTED', 'ACCEPTED', 'CREATED', 'READY');
      

      We are getting following error when creating the connector 

      java.lang.Object; cannot be cast to [Ljava.lang.String;","class<span class="code-quote">":"java.lang.ClassCastException","stacktrace":"java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
      io.debezium.connector.postgresql.TypeRegistry.createTypeBuilderFromResultSet(TypeRegistry.java:357)
      io.debezium.connector.postgresql.TypeRegistry.prime(TypeRegistry.java:320)
      io.debezium.connector.postgresql.TypeRegistry.<init>(TypeRegistry.java:126) 

      A little digging into the code here

       

      if (CATEGORY_ENUM.equals(category)) {
                  String[] enumValues = (String[]) rs.getArray("enum_values").getArray();
                  builder = builder.enumValues(Arrays.asList(enumValues));        }

      ResultSet.getArray("enum_values") - RETURNS: an Array object representing the SQL ARRAY value in the specified column
      and
      Array.getArray() - Returns an Object.

      I am not a Java expert so please pardon if my understanding here is wrong but it looks like it is trying to cast an Object[] to String array which based on the exception will always fail. I ran the  SQL_TEXT query from the code in my database and I can confirm that it returns what the code is expecting -

      NOTE: I went through prior issues that were raised regarding PostgresSQL ENUM and tried the configs which didn't work in my case.

      "column.propagate.source.type": ".*"
      "include.unknown.datatypes": "true"

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            naga.kondapaturi Naga Kondapaturi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: