Spark: test cleanup - eliminate unnecessary table refreshes#15765
Merged
huaxingao merged 1 commit intoapache:mainfrom Mar 26, 2026
Merged
Spark: test cleanup - eliminate unnecessary table refreshes#15765huaxingao merged 1 commit intoapache:mainfrom
huaxingao merged 1 commit intoapache:mainfrom
Conversation
huaxingao
approved these changes
Mar 25, 2026
ebyhr
approved these changes
Mar 26, 2026
singhpk234
approved these changes
Mar 26, 2026
Contributor
|
Thanks @wypoon for the PR! Thanks @ebyhr @singhpk234 for the review! |
Contributor
Author
|
Thanks @huaxingao @ebyhr and @singhpk234 for reviewing! |
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.
TestRewriteDataFilesActionhas helpercreateTableandcreateTablePartitionedmethods that create aTableinstance, write to the table, and return theTableinstance. However, as the write is done using theDataFrameAPI and not through theTable, theTableinstance that is returned is stale. This is bad design and a trap for unwary new users of the methods who want to add tests. The trap is made worse by the verification helper methodsshouldHaveFilesandshouldHaveSnapshots(which take theTableas an argument) doing aTable::refreshbefore performing its work, so if one looks at some existing test method that callscreateTablefollowed byshouldHaveFilesas a model, one does not see the hidden call toTable::refresh.The
Tableshould be refreshed before it is returned, so it has all the changes. The side-effectingTable::refreshcalls should be removed from verification helper methods. Once this is done, some newTable::refreshcalls need to be added. However, I found many unnecessaryTable::refreshcalls (probably added defensively due to being once bitten, twice shy) and have removed them.I also found and removed unnecessary
Table::refreshcalls inTestRewritePositionDeleteFilesAction.