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

Specific Data, newBuilder(existingInstance) fails for BigDecimal

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.8.2
    • None
    • java
    • None

    Description

      Using 1.8.2-rc3

      When attempting to use:
      MyType.newBuilder(existingType)

      With a field of type Union:

      ["null",{"type":"bytes","logicalType":"decimal","precision":20,"scale":8}]
      

      I get the following exception:

      org.apache.avro.UnresolvedUnionException: Not in union ["null",{"type":"bytes","logicalType":"decimal","precision":20,"scale":8}]: 12000.00000000
      
      	at org.apache.avro.generic.GenericData.resolveUnion(GenericData.java:740)
      	at org.apache.avro.generic.GenericData.deepCopyRaw(GenericData.java:1146)
      	at org.apache.avro.generic.GenericData.deepCopy(GenericData.java:1062)
      	at MyType$Builder.<init>
      

      I suspected it may be related but also noticed in the generated Specific Data class the following:

      private static final org.apache.avro.Conversion<?>[] conversions =
            new org.apache.avro.Conversion<?>[] {
            null,
            TIMESTAMP_CONVERSION,
            null,
            null, // Should be DECIMAL_CONVERSION
            null,
            null,
            null,
            null,
            null
        };
      

      ie, the conversion was missing.
      Adding this by hand however did not resolve the issue. I will add this as another issue.

      Attachments

        Activity

          People

            Unassigned Unassigned
            amccague Adrian McCague
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified