Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-3879

Null Avro Values

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.3.0
    • None
    • None

    Description

      I'm getting an error from the convertRecord processor saying an Avro Schema couldn't be found. I've narrowed it down to the processor thinking that my schema is invalid. Would it be possible to change the log message to say when the schema is invalid instead?

      In my schema I have a field that is optional, so I'm using a null default. This is what the processor thinks is invalid about it. I tried the same schema using the Java avro library and it seems like it's valid.

      I've attached an example template and here's the java code I'm using.

      Schema schema = new Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Test\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"deleted\",\"type\":[\"null\",\"boolean\"],\"default\":null}]}");
      GenericRecord t1 = new GenericData.Record(schema);
      t1.put("name", "Bob");
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      DatumWriter<GenericRecord> datumWriter = new GenericDatumWriter<GenericRecord>(schema);
      DataFileWriter<GenericRecord> dataFileWriter = new DataFileWriter<GenericRecord>(datumWriter);
      dataFileWriter.create(schema, out);
      dataFileWriter.append(t1);
      dataFileWriter.close();
      System.out.println(new String(out.toByteArray()));
      

      Attachments

        1. NullableField.xml
          18 kB
          Steve Champagne

        Issue Links

          Activity

            People

              Unassigned Unassigned
              champagst Steve Champagne
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: