Repository navigation
join: compare a missing join field as an empty one - #15875
Merged
Merged
Conversation
A line too short to have the join field was ordered before a line whose join field is empty, while `sort -k` gives both the same empty key. So `join --check-order` rejected input that `sort -k` had just sorted, and such lines never paired with each other. Closes uutils#15741
Contributor
|
Thanks! |
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.
Input::compareordered a line that is too short to have the join field before a line whose join field is empty.sort -kgives both the same empty key, so aftersort -t, -k2,2putsx,beforey,join -t, -1 2 --check-orderstopped withis not sorted: y. Those lines also never paired with each other.comparenow treats a missing field as an empty slice before the usual case-insensitive, locale or byte comparison. The order check, the main loop andState::extendall go through it, so this covers all three.Line::get_fieldstill returnsNone, so-efilling is unchanged.Added
test_missing_key_is_empty_keyintests/by-util/test_join.rs, covering--check-orderwith-t,, the self-join pairing, and the default blank separator with a trailing blank. The output matches GNU join run as a black box. It fails on main withjoin: short:2: is not sorted: y, and all 46test_join::tests pass with the fix.Closes #15741