Skip to content

Surface persistence exceptions to the caller more often #1348

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

eric-maynard
Copy link
Contributor

@eric-maynard eric-maynard commented Apr 9, 2025

In many ...Catalog methods like dropPolicy or dropGenericTable, we simply return false if there's a BaseResult from persistence that doesn't have a SUCCESS error code. In some cases like in IcebergCatalog we do a little better, mapping a small subset of failures into exceptions.

This PR pushes this mapping down into BaseResult so that methods which rely on BaseResult to report the success of a persistence call can pass accurate information about the error back to the caller (via the exception mapper in the case of a REST call).

In order to support some Iceberg tests that expect methods like dropTable not to throw an exception, this functionality is gated behind a feature flag DETAILED_PERSISTENCE_EXCEPTIONS

* If this result is failed, this should throw the appropriate exception which corresponds to the
* result status. See {@link BaseResult#getException} for details.
*/
public void maybeThrowException() throws RuntimeException {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This helper method is nice to have because you can't throw an exception from a lambda, so you can't do e.g. result.getException().foreach(e -> throw e)

@eric-maynard
Copy link
Contributor Author

Unfortunately some Iceberg tests essentially assert that these methods don't throw exceptions, e.g. testDropMissingTable does:

((AbstractBooleanAssert)Assertions.assertThat(catalog.dropTable(noSuchTableIdent)).as("Should not drop a table that does not exist", new Object[0])).isFalse();

To pass these tests, we may want to gate this new behavior behind a flag

@eric-maynard eric-maynard changed the title Surface failed BaseResults to the caller more often Surface persistence exceptions to the caller more often Apr 9, 2025
@eric-maynard eric-maynard marked this pull request as ready for review April 9, 2025 23:07

String message = this.extraInformation;
if (this.extraInformation == null) {
// TODO this should ideally never be hit but it's hit often.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we merge this, we should file an issue(s) tracking the many callsites where a non-successful result is built with a null message. This might be a good starter task.

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.

1 participant