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


##########
connector/protobuf/src/main/scala/org/apache/spark/sql/protobuf/utils/ProtobufUtils.scala:
##########
@@ -178,46 +176,73 @@ private[sql] object ProtobufUtils extends Logging {
   }
 
   def buildDescriptor(descFilePath: String, messageName: String): Descriptor = 
{
-    val descriptor = 
parseFileDescriptor(descFilePath).getMessageTypes.asScala.find { desc =>
-      desc.getName == messageName || desc.getFullName == messageName
-    }
+    val fileDescriptor = parseFileDescriptorSet(descFilePath)
+      .find(!_.getMessageTypes.asScala.find(desc =>

Review Comment:
   Oh, we need to find() invocations and check is made twice. How about this? 
[Optional to do, only a suggestion]
   
        // Find the first message descriptor that matches the name.
        val descriptorOpt =  parseFileDescriptorSet(descFilePath)
            .flatMap { fileDesc => 
                   fileDesc.getMessageTypes.asScala.find { desc => 
                         desc.getName == messageName || desc.getFullName == 
messageName
                   }
            }.headOption
   
         descriptoOpt match {
            case Some(d) => d
            case None => throw 
QueryCompilationErrors.unableToLocateProtobufMessageError(messageName)
        } 
         
   
   
   



-- 
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: reviews-unsubscr...@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to