YannByron commented on code in PR #5201:
URL: https://github.com/apache/hudi/pull/5201#discussion_r849141245
##########
hudi-common/src/main/java/org/apache/hudi/avro/HoodieAvroUtils.java:
##########
@@ -164,6 +164,18 @@ public static GenericRecord jsonBytesToAvro(byte[] bytes,
Schema schema) throws
return reader.read(null, jsonDecoder);
}
+ /**
+ * True if the schema contains this name of field
+ */
+ public static boolean containsFieldInSchema(Schema schema, String fieldName)
{
+ try {
+ Field field = schema.getField(fieldName);
+ return field != null;
+ } catch (Exception e) {
+ return false;
+ }
Review Comment:
Since avro 1.10, arvo will throw AvroRuntimeException rather than return
null like the previous version if record doesn't contain this key.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]