-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[Spark][kernel] Translate Kernel exceptions mentioned in Issue #5900 #7071
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
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 |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |
| import io.delta.kernel.data.FilteredColumnarBatch; | ||
| import io.delta.kernel.defaults.engine.DefaultEngine; | ||
| import io.delta.kernel.engine.Engine; | ||
| import io.delta.kernel.exceptions.UnsupportedProtocolVersionException; | ||
| import io.delta.kernel.exceptions.UnsupportedTableFeatureException; | ||
| import io.delta.kernel.internal.DeltaHistoryManager; | ||
| import io.delta.kernel.internal.DeltaLogActionUtils.DeltaAction; | ||
|
|
@@ -499,6 +500,16 @@ public Offset latestOffset(Offset startOffset, ReadLimit limit) { | |
| if (interruptCause.isPresent()) { | ||
| throw new UncheckedIOException(interruptCause.get()); | ||
| } | ||
| // Translate Kernel's protocol-version error into Delta's InvalidProtocolVersionException. | ||
| Optional<UnsupportedProtocolVersionException> protocolCause = findUnsupportedProtocolCause(e); | ||
| if (protocolCause.isPresent()) { | ||
| UnsupportedProtocolVersionException p = protocolCause.get(); | ||
| boolean isReader = | ||
| p.getVersionType() == UnsupportedProtocolVersionException.ProtocolVersionType.READER; | ||
| throw (RuntimeException) | ||
| DeltaErrors.invalidProtocolVersionError( | ||
| p.getTablePath(), isReader ? p.getVersion() : 0, isReader ? 0 : p.getVersion()); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This loses part of the table protocol when translating to Delta's
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed, |
||
| } | ||
| throw e; | ||
| } | ||
| } | ||
|
|
@@ -747,6 +758,22 @@ static Optional<ClosedByInterruptException> findClosedByInterruptCause(Throwable | |
| return Optional.empty(); | ||
| } | ||
|
|
||
| /** | ||
| * Walks the cause chain of the given throwable looking for a Kernel {@link | ||
| * UnsupportedProtocolVersionException}. | ||
| */ | ||
| static Optional<UnsupportedProtocolVersionException> findUnsupportedProtocolCause(Throwable t) { | ||
| for (Throwable current = t; current != null; current = current.getCause()) { | ||
| if (current instanceof UnsupportedProtocolVersionException) { | ||
| return Optional.of((UnsupportedProtocolVersionException) current); | ||
| } | ||
| if (current.getCause() == current) { | ||
| break; | ||
| } | ||
| } | ||
| return Optional.empty(); | ||
| } | ||
|
|
||
| private boolean isExcludedPath(String path) { | ||
| return excludeRegex.isPresent() && excludeRegex.get().findFirstIn(path).isDefined(); | ||
| } | ||
|
|
||
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's kernel's behavior when there is no log file?
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.
Kernel throws
TableNotFoundException