Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-3654

BigDecimal not supported in GenericData.getSchemaName() method

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Critical
    • Resolution: Unresolved
    • 1.11.1
    • None
    • java
    • None

    Description

      When trying to add a `GenericRecord` in a Java set, the hashcode computation code is called.

      If a Union contains a decimal logical type which is mapped with a `BigDecimal` in Java, the call to `add` will fail with:

      Caused by: org.apache.avro.AvroRuntimeException: Unknown datum type java.math.BigDecimal: 4042030.00
      	at org.apache.avro.generic.GenericData.getSchemaName(GenericData.java:933)
      	at org.apache.avro.generic.GenericData.resolveUnion(GenericData.java:892)
      	at org.apache.avro.generic.GenericData.hashCode(GenericData.java:1113)
      	at org.apache.avro.generic.GenericData.hashCodeAdd(GenericData.java:1127)
      	at org.apache.avro.generic.GenericData.hashCode(GenericData.java:1103)
      	at org.apache.avro.generic.GenericData.hashCode(GenericData.java:1113)
      	at org.apache.avro.generic.GenericData.hashCodeAdd(GenericData.java:1127)
      	at org.apache.avro.generic.GenericData.hashCode(GenericData.java:1103)
      	at org.apache.avro.generic.GenericData$Record.hashCode(GenericData.java:292)
      	at java.base/java.util.HashMap.hash(HashMap.java:338)
      	at java.base/java.util.HashMap.put(HashMap.java:610)
      	at java.base/java.util.HashSet.add(HashSet.java:221)
      

      The method `getSchemaName` does not handle the BigDecimal Java type, which is used by the `DecimalConversion`.

      Attachments

        Activity

          People

            Unassigned Unassigned
            ebrard Emmanuel Brard
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: