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

Negative decimal number scale is not supported by Avro

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.1.0.Beta1
    • None
    • oracle-connector
    • None

      Oracle connector allows to use negative scale for NUMBER type: A negative scale indicates rounding in Oracle, for example, a scale of -2 causes rounding to hundreds.

      Typically, the scale factor is stored in the registry. However, Avro specification doesn't allow negative scales: Scale must be zero or a positive integer less than or equal to the precision.

      When Debezium is used with Apicurio schema registry, which require the scale to be positive, storing NUMBER with negative scale fails with

      Problem with message on topic 'server1.DEBEZIUM.TYPE_INT':
      java.lang.IllegalArgumentException: Invalid decimal scale: -2 (must be positive)
              at org.apache.avro.LogicalTypes$Decimal.validate(LogicalTypes.java:255)
              at org.apache.avro.LogicalType.addToSchema(LogicalType.java:68)
              at org.apache.avro.LogicalTypes$Decimal.addToSchema(LogicalTypes.java:227)
              at io.apicurio.registry.utils.converter.avro.AvroData.fromConnectSchema(AvroData.java:947)
              at io.apicurio.registry.utils.converter.avro.AvroData.addAvroRecordField(AvroData.java:1062)
              at io.apicurio.registry.utils.converter.avro.AvroData.fromConnectSchema(AvroData.java:903)
              at io.apicurio.registry.utils.converter.avro.AvroData.fromConnectSchemaWithCycle(AvroData.java:1025)
              at io.apicurio.registry.utils.converter.avro.AvroData.fromConnectSchema(AvroData.java:890)
              at io.apicurio.registry.utils.converter.avro.AvroData.addAvroRecordField(AvroData.java:1062)
              at io.apicurio.registry.utils.converter.avro.AvroData.fromConnectSchema(AvroData.java:903)
              at io.apicurio.registry.utils.converter.avro.AvroData.fromConnectSchema(AvroData.java:735)
              at io.apicurio.registry.utils.converter.avro.AvroData.fromConnectSchema(AvroData.java:729)
              at io.apicurio.registry.utils.converter.avro.AvroData.fromConnectData(AvroData.java:368)
              at io.apicurio.registry.utils.converter.AvroConverter.applySchema(AvroConverter.java:81)
              at io.apicurio.registry.utils.converter.SerdeBasedConverter.fromConnectData(SerdeBasedConverter.java:116)
      

      This can be reproduced by running Oracle connector SnapshotDatatypesIT#intTypes test against Apicurio schema registry.

              vjuranek@redhat.com Vojtech Juranek
              vjuranek@redhat.com Vojtech Juranek
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: