Skip to content
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

Spark3.5: Standardizing Error Handling in Iceberg Spark Module - TestViews #11993

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

Conversation

huaxingao
Copy link
Contributor

Changing error validation from checking error message to validating error classes in Spark module, starting from TestViews. Here is the original discussion.

@github-actions github-actions bot added the spark label Jan 17, 2025
@@ -213,10 +213,13 @@ public void readFromViewUsingNonExistingTable() throws NoSuchTableException {

assertThatThrownBy(() -> sql("SELECT * FROM %s", viewName))
.isInstanceOf(AnalysisException.class)
.hasMessageContaining(
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer if we could keep the error msg check. I think it's perfectly fine to keep this and then just add the .satisfies check below

Copy link
Contributor

Choose a reason for hiding this comment

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

If we really only care about the error class, then an alternative check could be the one below:

assertThatThrownBy(() -> sql("SELECT * FROM %s", viewName))
        .isInstanceOf(AnalysisException.class)
        .hasMessageContaining(
            String.format(
                "The table or view `%s`.`%s`.`non_existing` cannot be found",
                catalogName, NAMESPACE))
        .asInstanceOf(InstanceOfAssertFactories.type(AnalysisException.class))
        .extracting(AnalysisException::getErrorClass)
        .isEqualTo("INVALID_VIEW_TEXT");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @nastra for your comment! I'm concerned that checking for specific error messages might make the tests a bit fragile. While this particular error message seems stable, others might change between versions. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say let's keep the error messages for now until we actually see that those become more difficult to maintain because they change more frequently (which I actually don't expect to happen). The reason I'd like to keep the error msg is to make sure that we properly ensure and see what a typical end user would see when a certain error condition happens

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.

2 participants