heyihong commented on code in PR #42377:
URL: https://github.com/apache/spark/pull/42377#discussion_r1310143393
##########
connector/connect/common/src/main/scala/org/apache/spark/sql/connect/client/GrpcExceptionConverter.scala:
##########
@@ -64,6 +69,94 @@ private[client] object GrpcExceptionConverter extends
JsonUtils {
}
}
+ private def enrichError(errors: Array[Error], info: ErrorInfo): Array[Error]
= {
+ val sessionId = info.getMetadataOrDefault("sessionId", null)
+ val userId = info.getMetadataOrDefault("userId", null)
+
+ if (sessionId == null || userId == null) {
+ return errors
+ }
+
+ try {
+ val errorInfoResponse = stub.getErrorInfo(
+ GetErrorInfoRequest
+ .newBuilder()
+ .setSessionId(sessionId)
+ .addAllErrorIds(errors.map(_.errorId).toIterable.asJava)
+ .setUserContext(UserContext.newBuilder().setUserId(userId).build())
+ .build())
+
+ val exceptionInfos = errorInfoResponse.getExceptionInfosList.asScala
+
+ errors.map { error =>
+ exceptionInfos.find(_.getErrorId == error.errorId) match {
+ case Some(exceptionInfo) =>
+ val stackTraceOpt =
+ if (exceptionInfo.getStackTraceList.isEmpty) None
+ else {
+ Some(exceptionInfo.getStackTraceList.asScala.toArray.map {
stackTraceElement =>
+ new StackTraceElement(
+ stackTraceElement.getDeclaringClass,
+ stackTraceElement.getMethodName,
+ stackTraceElement.getFileName,
+ stackTraceElement.getLineNumber)
+ })
+ }
+ Error(
+ errorId = error.errorId,
+ classes = error.classes,
+ message = exceptionInfo.getMessage,
+ stackTraceOpt = stackTraceOpt)
+ case None =>
+ error
+ }
+ }
+ } catch {
+ case _: StatusRuntimeException => errors
Review Comment:
The current expectation on this additional rpc call is best effort and at
most once so no?
##########
connector/connect/common/src/main/scala/org/apache/spark/sql/connect/client/GrpcExceptionConverter.scala:
##########
@@ -64,6 +69,94 @@ private[client] object GrpcExceptionConverter extends
JsonUtils {
}
}
+ private def enrichError(errors: Array[Error], info: ErrorInfo): Array[Error]
= {
+ val sessionId = info.getMetadataOrDefault("sessionId", null)
+ val userId = info.getMetadataOrDefault("userId", null)
+
+ if (sessionId == null || userId == null) {
+ return errors
+ }
+
+ try {
+ val errorInfoResponse = stub.getErrorInfo(
+ GetErrorInfoRequest
+ .newBuilder()
+ .setSessionId(sessionId)
+ .addAllErrorIds(errors.map(_.errorId).toIterable.asJava)
+ .setUserContext(UserContext.newBuilder().setUserId(userId).build())
+ .build())
+
+ val exceptionInfos = errorInfoResponse.getExceptionInfosList.asScala
+
+ errors.map { error =>
+ exceptionInfos.find(_.getErrorId == error.errorId) match {
+ case Some(exceptionInfo) =>
+ val stackTraceOpt =
+ if (exceptionInfo.getStackTraceList.isEmpty) None
+ else {
+ Some(exceptionInfo.getStackTraceList.asScala.toArray.map {
stackTraceElement =>
+ new StackTraceElement(
+ stackTraceElement.getDeclaringClass,
+ stackTraceElement.getMethodName,
+ stackTraceElement.getFileName,
+ stackTraceElement.getLineNumber)
+ })
+ }
+ Error(
+ errorId = error.errorId,
+ classes = error.classes,
+ message = exceptionInfo.getMessage,
+ stackTraceOpt = stackTraceOpt)
+ case None =>
+ error
+ }
+ }
+ } catch {
+ case _: StatusRuntimeException => errors
Review Comment:
No? The current expectation on this additional rpc call is best effort and
at most once
--
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]