rangadi commented on code in PR #40983:
URL: https://github.com/apache/spark/pull/40983#discussion_r1180582637


##########
connector/protobuf/src/main/scala/org/apache/spark/sql/protobuf/ProtobufDataToCatalyst.scala:
##########
@@ -63,7 +64,16 @@ private[protobuf] case class ProtobufDataToCatalyst(
   @transient private lazy val fieldsNumbers =
     messageDescriptor.getFields.asScala.map(f => f.getNumber).toSet
 
-  @transient private lazy val deserializer = new 
ProtobufDeserializer(messageDescriptor, dataType)
+  @transient private lazy val deserializer = {
+    val typeRegistry = descFilePath match {
+      case Some(path) if protobufOptions.convertAnyFieldsToJson =>
+        ProtobufUtils.buildTypeRegistry(path) // This loads all the messages 
in the file.
+      case None if protobufOptions.convertAnyFieldsToJson =>
+        ProtobufUtils.buildTypeRegistry(messageDescriptor) // Loads only 
connected messages.
+      case _ => TypeRegistry.getEmptyTypeRegistry // Default. Json conversion 
is not enabled.
+    }
+    new ProtobufDeserializer(messageDescriptor, dataType, typeRegistry = 
typeRegistry)
+  }

Review Comment:
   Both are similar, but not exactly same. `buildDescriptor()` has better error 
message meant for compile time error for the user. In addition, it supports 
matching just the message name rather than full name. We can keep this way.



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