the-other-tim-brown commented on code in PR #6806:
URL: https://github.com/apache/hudi/pull/6806#discussion_r981750304


##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/sources/helpers/ProtoConversionUtil.java:
##########
@@ -173,24 +184,35 @@ private Schema getMessageSchema(Descriptors.Descriptor 
descriptor, CopyOnWriteMa
       List<Schema.Field> fields = new 
ArrayList<>(descriptor.getFields().size());
       for (Descriptors.FieldDescriptor f : descriptor.getFields()) {
         // each branch of the schema traversal requires its own recursion 
depth tracking so copy the recursionDepths map
-        fields.add(new Schema.Field(f.getName(), getFieldSchema(f, new 
CopyOnWriteMap<>(recursionDepths), flattenWrappedPrimitives, path, 
maxRecursionDepth), null, getDefault(f)));
+        fields.add(new Schema.Field(f.getName(), getFieldSchema(f, new 
CopyOnWriteMap<>(recursionDepths), wrappedPrimitivesAsRecords, path, 
maxRecursionDepth, timestampsAsRecords),
+            null, getDefault(f)));
       }
       result.setFields(fields);
       return result;
     }
 
-    private Schema getFieldSchema(Descriptors.FieldDescriptor f, 
CopyOnWriteMap<Descriptors.Descriptor, Integer> recursionDepths, boolean 
flattenWrappedPrimitives, String path,
-                                  int maxRecursionDepth) {
-      Function<Schema, Schema> schemaFinalizer =  f.isRepeated() ? 
Schema::createArray : Function.identity();
-      switch (f.getType()) {
+    private Schema getFieldSchema(Descriptors.FieldDescriptor fieldDescriptor, 
CopyOnWriteMap<Descriptors.Descriptor, Integer> recursionDepths, boolean 
wrappedPrimitivesAsRecords, String path,
+                                  int maxRecursionDepth, boolean 
timestampsAsRecords) {
+      Function<Schema, Schema> schemaFinalizer = schema -> {
+        Schema updatedSchema = schema;
+        // all fields in the oneof will be treated as nullable
+        if (fieldDescriptor.getContainingOneof() != null && !(schema.getType() 
== Schema.Type.UNION && schema.getTypes().get(0).getType() == 
Schema.Type.NULL)) {

Review Comment:
   if you are referring to `schema.isNullable()`, that method does not exist in 
older avro versions that we support



-- 
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: commits-unsubscr...@hudi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to