Spark: Fail fast when metadata file location is null in BaseSparkAction#16846
Open
bobmerevel wants to merge 2 commits into
Open
Spark: Fail fast when metadata file location is null in BaseSparkAction#16846bobmerevel wants to merge 2 commits into
bobmerevel wants to merge 2 commits into
Conversation
- A new `Preconditions` check is added to ensure that the `metadataFileLocation()` returns a non-null value when creating a static table, including improved error handling and validation in the code. - Introduced a test class `TestBaseSparkAction` with a single test method `testNewStaticTableFailsWhenMetadataLocationIsNull`, which tests the behavior of a Spark action when the metadata file location is null.
3 tasks
ebyhr
reviewed
Jun 18, 2026
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.io.TempDir; | ||
|
|
||
| public class TestBaseSparkAction extends TestBase { |
Member
There was a problem hiding this comment.
Could you follow https://iceberg.apache.org/contribute/#conventions-and-recommendations ?
- Omit the public modifier for test classes, test methods, and lifecycle methods for newly added tests.
- Omit the test prefix for newly added test methods.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes are proposed in this pull request?
This PR adds a fail-fast validation in
BaseSparkAction.newStaticTable()to ensure thatTableMetadata.metadataFileLocation()is not null before constructing aBaseTable.Currently, if the metadata file location is null, the Spark action proceeds further into execution and eventually fails with a
NullPointerException, making the actual root cause difficult to diagnose.The new validation makes this precondition explicit and produces a more meaningful error message.
Why are the changes needed?
This improves diagnostics for invalid
TableMetadatainstances and prevents failures from surfacing much later during Spark job execution.The intent is not to support invalid catalog implementations, but to fail earlier with a clearer message when the required precondition is violated.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Added a unit test covering the case where
metadataFileLocation()is null and verified thatnewStaticTable()fails with an explicit exception.AI assistance disclosure:
I used AI assistance while drafting the PR description and exploring possible test implementations. The final implementation and testing were reviewed and verified manually.
Closes #16838