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

Exception when trying to write object with Nullable field that is of Stringable type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.2
    • 1.7.2
    • java

    Description

      There seems to be an issue with stringable fields that are nullable. I'm mostly using ReflectData.AllowNull in my real usage of this feature and I'm seeing it fail with this:

      org.apache.avro.AvroRuntimeException: Unknown datum type: 10
      	at org.apache.avro.generic.GenericData.getSchemaName(GenericData.java:574)
      	at org.apache.avro.generic.GenericData.resolveUnion(GenericData.java:539)
      	at org.apache.avro.generic.GenericDatumWriter.resolveUnion(GenericDatumWriter.java:137)
      	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:70)
      	at org.apache.avro.reflect.ReflectDatumWriter.write(ReflectDatumWriter.java:104)
      	at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:105)
      	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:65)
      	at org.apache.avro.reflect.ReflectDatumWriter.write(ReflectDatumWriter.java:104)
      	at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:57)
      

      Here's a quick test that shows this problem:

      public static class N1 {
            BigDecimal number;
        }
      
        @Test public void testNullableStringableField() throws Exception {
            N1 datum = new N1();
            datum.number = BigDecimal.TEN;
      
            checkBinary(ReflectData.AllowNull.get(), ReflectData.AllowNull.get().getSchema(N1.class), datum, false);
        }
      

      Attachments

        1. AVRO-1153.patch
          3 kB
          Alexandre Normand
        2. AVRO-1153.patch
          2 kB
          Alexandre Normand
        3. AVRO-1153.patch
          2 kB
          Alexandre Normand
        4. AVRO-1153.patch
          2 kB
          Alexandre Normand

        Activity

          People

            alexandre.normand Alexandre Normand
            alexandre.normand Alexandre Normand
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: