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


##########
connector/protobuf/src/main/scala/org/apache/spark/sql/protobuf/utils/ProtobufUtils.scala:
##########
@@ -196,30 +194,52 @@ private[sql] object ProtobufUtils extends Logging {
       fileDescriptorSet = DescriptorProtos.FileDescriptorSet.parseFrom(dscFile)
     } catch {
       case ex: InvalidProtocolBufferException =>
-        // TODO move all the exceptions to 
core/src/main/resources/error/error-classes.json
-        throw new RuntimeException("Error parsing descriptor byte[] into 
Descriptor object", ex)
+        throw QueryCompilationErrors.descrioptorParseError(ex)
       case ex: IOException =>
-        throw new RuntimeException(
-          "Error reading Protobuf descriptor file at path: " +
-            descFilePath,
-          ex)
+        throw 
QueryCompilationErrors.cannotFindDescriptorFileError(descFilePath, ex)
     }
-
-    val descriptorProto: DescriptorProtos.FileDescriptorProto = 
fileDescriptorSet.getFile(0)
     try {
-      val fileDescriptor: Descriptors.FileDescriptor = 
Descriptors.FileDescriptor.buildFrom(
-        descriptorProto,
-        new Array[Descriptors.FileDescriptor](0))
+      val fileDescriptorProtoIndex = 
createDescriptorProtoMap(fileDescriptorSet)
+      val fileDescriptor: Descriptors.FileDescriptor =
+        buildFileDescriptor(fileDescriptorSet.getFileList.asScala.last, 
fileDescriptorProtoIndex)

Review Comment:
   @rangadi I removed this option on purpose; since the user would pass the 
main descriptor file as a parameter, we should just look at the main 
descriptor. What if the user has the same MessageName in multiple .proto files? 
Which one should we read?
   
   the descriptor structure is first imports, then message definition, with 
this assumption "last" would be the main message definition. 
   
   how about looking at the main message definition first, if don't find we can 
look at the "imports" return as soon as the messagename matches.?     
   
   



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