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


##########
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)) {
+          updatedSchema = makeSchemaNullable(schema);
+        }
+        if (fieldDescriptor.isRepeated()) {

Review Comment:
   You can't have a repeated field inside of a `oneOf` but I switched the order 
anyways



-- 
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]

Reply via email to