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

To fetch all the failure attributes in case of schema validation failure

    XMLWordPrintableJSON

Details

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

    Description

      When we are validating AVRO schema against payload we just get one failed attribute information only. While in case of multiple attribute failure for a big schema it becomes difficult to correct the payload. Can it be corrected in the library so that we get all the information as in JSON we get.

      Schema ::

      {    "namespace": "tutorialspoint.com",    "type": "record",    "name": "emp",    "fields": [       \{"name": "name", "type": "string"}

      ,
            {"name": "id", "type": "int"},
            {"name": "salary", "type": "int"},
            {"name": "age", "type": "int"},
            {"name": "address", "type": "string"}
         ]
      }

      Test cases:
      Test case 1.
      Success Payload 
      {"emp":{"name":"alex","id":2,"age":23,"salary":2000,"address":"xyz"}}

      Test case 2.
      Failure payload with 2 attributes wrong type(Address and salary)::
      {"emp":{"name":"alex","id":2,"age":23,"salary":"Twenty thousand","address":123}}

      Code implemented:
      Schema schema = new Schema.Parser().parse(strSchema);
              try

      {             JsonAvroConverter avroConverter = new JsonAvroConverter();             avroConverter.convertToGenericDataRecord(payload.getBytes(), schema);             LoggerUtility.writeLogger(SchemaValidator.class, LogLevel.INFO, "AVRO Schema successfully validated...");         }

      catch (AvroRuntimeException e)

      {             throw new SerializationException("AVRO does not match schema ", e);         }

      Problem:

      we want to get all the failures while validating the AVRO schema against payload. The avro library used in above code returns only one failure.
      But in the Test case 2 in exception it just returns one failure not both.

      Attachments

        Activity

          People

            Unassigned Unassigned
            prateekjoshi24 Prateek Joshi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: