Prateek Joshi created AVRO-3429:
-----------------------------------

             Summary: To fetch all the failure attributes in case of schema 
validation failure
                 Key: AVRO-3429
                 URL: https://issues.apache.org/jira/browse/AVRO-3429
             Project: Apache Avro
          Issue Type: Bug
            Reporter: Prateek Joshi


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.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to