Skip to content

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.

@github-actions
Copy link

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions
Copy link

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Jun 18, 2025
@github-project-automation github-project-automation bot moved this from PRs In Progress to Done in Basic Kanban Board Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant