-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-40777][SQL][PROTOBUF] Protobuf import support and move error-classes. #38344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
c6177a3
8fad018
dac2fa8
d1c9b1e
03b918f
60c2122
7c866de
e6f3cab
70a5983
26e471b
68f87c1
9cdf4d5
4e1080e
dbaf24d
6045ffe
3fc59b5
e5482a5
dd63be8
e5140b0
3037415
be02c9e
d8cce82
ad1f7e1
48bcb5c
87918a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -175,19 +175,26 @@ private[sql] object ProtobufUtils extends Logging { | |
| .asInstanceOf[Descriptor] | ||
| } | ||
|
|
||
| // TODO: Revisit to ensure that messageName is searched through all imports | ||
| def buildDescriptor(descFilePath: String, messageName: String): Descriptor = { | ||
| val descriptor = parseFileDescriptor(descFilePath).getMessageTypes.asScala.find { desc => | ||
| desc.getName == messageName || desc.getFullName == messageName | ||
| val descriptorList = parseFileDescriptor(descFilePath).map(fileDescriptor => { | ||
|
||
| fileDescriptor.getMessageTypes.asScala.find { desc => | ||
| desc.getName == messageName || desc.getFullName == messageName | ||
| } | ||
| }).filter(f => !f.isEmpty) | ||
|
|
||
| if (descriptorList.isEmpty) { | ||
| throw QueryCompilationErrors.noProtobufMessageTypeReturnError(messageName) | ||
| } | ||
|
|
||
| descriptor match { | ||
| descriptorList.last match { | ||
|
||
| case Some(d) => d | ||
| case None => | ||
| throw QueryCompilationErrors.unableToLocateProtobufMessageError(messageName) | ||
| } | ||
| } | ||
|
|
||
| private def parseFileDescriptor(descFilePath: String): Descriptors.FileDescriptor = { | ||
| private def parseFileDescriptor(descFilePath: String): List[Descriptors.FileDescriptor] = { | ||
|
||
| var fileDescriptorSet: DescriptorProtos.FileDescriptorSet = null | ||
| try { | ||
| val dscFile = new BufferedInputStream(new FileInputStream(descFilePath)) | ||
|
|
@@ -200,12 +207,11 @@ private[sql] object ProtobufUtils extends Logging { | |
| } | ||
| try { | ||
| val fileDescriptorProtoIndex = createDescriptorProtoMap(fileDescriptorSet) | ||
| val fileDescriptor: Descriptors.FileDescriptor = | ||
| buildFileDescriptor(fileDescriptorSet.getFileList.asScala.last, fileDescriptorProtoIndex) | ||
| if (fileDescriptor.getMessageTypes().isEmpty()) { | ||
| throw QueryCompilationErrors.noProtobufMessageTypeReturnError(fileDescriptor.getName()) | ||
| } | ||
| fileDescriptor | ||
| val fileDescriptorList: List[Descriptors.FileDescriptor] = | ||
| fileDescriptorSet.getFileList.asScala.map( fileDescriptorProto => | ||
| buildFileDescriptor(fileDescriptorProto, fileDescriptorProtoIndex) | ||
| ).toList | ||
| fileDescriptorList | ||
| } catch { | ||
| case e: Descriptors.DescriptorValidationException => | ||
| throw QueryCompilationErrors.failedParsingDescriptorError(e) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is missing? Looks fairly complete to me.
Better to state the problem here.