Skip to content

API: Add tests for CharSequenceUtil - #17890

Open
damansingh1313 wants to merge 2 commits into
apache:mainfrom
damansingh1313:api-add-charsequenceutil-tests
Open

API: Add tests for CharSequenceUtil#17890
damansingh1313 wants to merge 2 commits into
apache:mainfrom
damansingh1313:api-add-charsequenceutil-tests

Conversation

@damansingh1313

Copy link
Copy Markdown
Contributor

CharSequenceUtil.unequalPaths had no unit coverage even though it is used on the position delete write path in FileScopedPositionDeleteWriter. Add tests covering the same-reference and equal-content fast paths, differing lengths, differences at the first and last characters, and empty inputs.

CharSequenceUtil.unequalPaths had no unit coverage even though it is used on the
position delete write path in FileScopedPositionDeleteWriter. Add tests covering
the same-reference and equal-content fast paths, differing lengths, differences
at the first and last characters, and empty inputs.
@github-actions github-actions Bot added the API label Aug 30, 2026
@damansingh1313

Copy link
Copy Markdown
Contributor Author

Hi @huaxingao @szehon-ho
Could you please review the PR.

Comment on lines +49 to +51
// paths are compared from the end, so a trailing difference is found immediately
assertThat(CharSequenceUtil.unequalPaths("data/file-1.parquet", "data/file-2.parquet"))
.isTrue();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

a trailing difference

I can understand the intention, but the actual difference (1 vs 2) exists in the middle of the path. The unequalPaths method doesn't care about the separator. Also, the test name looks misleading.

I suggest adding another case where the last character is distinctly different. This way, we can cover three cases: the first, middle, and last character.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @ebyhr — you're right that it's a middle-of-string difference. I've renamed that case to ...WhenAMiddleCharacterDiffers, fixed the comments, and added a real last-character case (data/part-00001 vs data/part-00002), so first/middle/last are all covered now. Pushed as a follow-up.

The "data/file-1.parquet" vs "data/file-2.parquet" pair differs in the
middle of the string, not at the end, so rename that case accordingly and
add a dedicated case where only the final character differs. The three
positive cases now cover a difference at the first, a middle, and the last
character.
@damansingh1313
damansingh1313 requested a review from ebyhr September 1, 2026 11:01
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