chaoqin-li1123 commented on code in PR #44643:
URL: https://github.com/apache/spark/pull/44643#discussion_r1457988505


##########
connector/protobuf/src/test/scala/org/apache/spark/sql/protobuf/ProtobufFunctionsSuite.scala:
##########
@@ -1150,6 +1221,32 @@ class ProtobufFunctionsSuite extends QueryTest with 
SharedSparkSession with Prot
     }
   }
 
+  test("Retain empty recursive proto fields when 
retain.empty.message.types=true") {
+    // This verifies that a empty proto like 'message A { A a = 1}' can be 
retained by
+    // inserting a dummy field.
+
+    val emptyProtoSchema =
+      StructType(StructField("__dummy_field_in_empty_struct", StringType) :: 
Nil)
+    val expectedSchema = StructType(
+      StructField("empty_proto",
+        StructType(
+          StructField("recursive_field", emptyProtoSchema) ::
+            StructField("recursive_array", ArrayType(emptyProtoSchema, 
containsNull = false)
+          ) :: Nil
+        )
+      ) :: Nil
+    )
+
+    val options = Map("recursive.fields.max.depth" -> "2", 
"retain.empty.message.types" -> "true")

Review Comment:
   yes, schema will change for recursive empty field if the option changed.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to