Skip to content

[Kernel] Add specific exception subclasses for loadSnapshotAt version failures#7055

Open
GabrielBBaldez wants to merge 1 commit into
delta-io:masterfrom
GabrielBBaldez:kernel-typed-version-load-exceptions
Open

[Kernel] Add specific exception subclasses for loadSnapshotAt version failures#7055
GabrielBBaldez wants to merge 1 commit into
delta-io:masterfrom
GabrielBBaldez:kernel-typed-version-load-exceptions

Conversation

@GabrielBBaldez

Copy link
Copy Markdown

Which Delta project/connector is this regarding?

  • Kernel

Description

When loading a snapshot at a specific version, SnapshotManager currently signals both out-of-range failures with a generic KernelException, so callers can only tell them apart by string-matching the message.

This adds two typed subclasses of KernelException and returns them from the corresponding DeltaErrors factory methods:

  • VersionToLoadAfterLatestCommitException — the requested version is higher than the latest commit (not materialized yet; typically recoverable by retrying).
  • VersionTruncatedException — the requested version is lower than the earliest available commit because the log has been truncated (unrecoverable for that version).

Both extend KernelException, mirroring how DeltaErrors#missingCheckpoint already returns an InvalidTableException. Connectors can now catch the specific type instead of parsing the message — e.g. the delta-spark V2 CDC SparkMicroBatchStream can swallow VersionToLoadAfterLatestCommitException to wait for the version to be committed.

Resolves #6745.

How was this patch tested?

Updated the existing SnapshotManagerSuite cases that exercise these two paths (getLogSegmentForVersion: versionToLoad higher than possible and ... not constructable from history) to assert the specific exception type is thrown instead of the generic RuntimeException.

Does this PR introduce any user-facing changes?

No behavioral change: both new types extend KernelException, so existing catch (KernelException ...) keeps working and the messages are unchanged. Callers simply gain the option to catch the narrower types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Kernel] Specific exception subclasses for loadSnapshotAt version failures

1 participant