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


##########
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:
   There is one more related issue here: We can find messages defined in this 
file, but not the message defined inside the imported file. 
   
   I think it is better to fix all of this properly, since you are already 
working on this. 
   I.e. we should be able to use any message defined in the descriptor file. 
   Essentially we can build `List [ FileDescriptor ]` and search for user's 
message in all of those. We could give preference for `last` if in this search 
order.
   



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