Skip to content

[Spark][kernel] Translate Kernel exceptions mentioned in Issue #5900#7071

Open
sotikoug83 wants to merge 2 commits into
delta-io:masterfrom
sotikoug83:kernel-exception-mismatches-5900-scoped
Open

[Spark][kernel] Translate Kernel exceptions mentioned in Issue #5900#7071
sotikoug83 wants to merge 2 commits into
delta-io:masterfrom
sotikoug83:kernel-exception-mismatches-5900-scoped

Conversation

@sotikoug83

@sotikoug83 sotikoug83 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Which Delta project/connector is this regarding?

  • Spark
  • Standalone
  • Flink
  • Kernel
  • Other (fill in here)

Description

Resolves #5900
(Scoped down from #7025)

When using DSv2 connector, two streaming reads surface Kernel-native exceptions instead of the Spark/Delta exceptions the DSv1 path raises. This PR translates them at their surfacing points to be consistent with DSv1:

  1. Reading a path whose _delta_log directory exists but contains no commits now throws org.apache.spark.sql.AnalysisException (DELTA_SCHEMA_NOT_SET) instead of Kernel's TableNotFoundException.
  2. A running stream that gets to an unsupported reader protocol version now fails with org.apache.spark.sql.delta.InvalidProtocolVersionException instead of Kernel's UnsupportedProtocolVersionException.

The translations are inline as such:

  • DeltaErrors gains throwSchemaNotSet() and an invalidProtocolVersionError(...) factory.
  • DeltaV2Table translates TableNotFoundException on initial snapshot load.
  • SparkMicroBatchStream translates UnsupportedProtocolVersionException in latestOffset.

How was this patch tested?

Enabled the two previously expected-to-fail tests in DeltaV2SourceSuite:

  • no schema should throw an exception
  • Delta sources should verify the protocol reader version

All test runs still passed after.

Does this PR introduce any user-facing changes?

No

}

/** Returns whether the table's {@code _delta_log} directory exists. */
private boolean deltaLogDirExists() {

Copy link
Copy Markdown
Collaborator

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kernel throws TableNotFoundException

@huan233usc huan233usc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left one comment on the protocol-version exception translation.

p.getVersionType() == UnsupportedProtocolVersionException.ProtocolVersionType.READER;
throw (RuntimeException)
DeltaErrors.invalidProtocolVersionError(
p.getTablePath(), isReader ? p.getVersion() : 0, isReader ? 0 : p.getVersion());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loses part of the table protocol when translating to Delta's InvalidProtocolVersionException. DSv1 builds that exception with both tableProtocol.minReaderVersion and tableProtocol.minWriterVersion; here a reader-side Kernel error reports writerRequired=0 in the DELTA_INVALID_PROTOCOL_VERSION message, which is not a valid table requirement and is still not DSv1-equivalent. Can we preserve the full Protocol when doing the translation, or use a factory/error shape that does not invent the missing side?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, UnsupportedProtocolVersionException now carries the full protocol.

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.

[Feature Request] DSv1 & Kernel exception mismatches

2 participants