Add name-based column modification to CsvSchema.Builder (#699) - #703
Merged
cowtowncoder merged 6 commits intoJul 24, 2026
Merged
Conversation
OrangeDog
reviewed
Jul 21, 2026
| /** | ||
| * Method for renaming an existing column, located by its current name | ||
| * instead of by index. If no column with given {@code oldName} exists, | ||
| * an {@link IllegalArgumentException} is thrown. |
There was a problem hiding this comment.
Shouldn't it be
@throws IllegalArgumentException if no column with given {@code oldName} exists
?
Contributor
Author
There was a problem hiding this comment.
Good catch — you're right. Converted the prose note into a proper @throws IllegalArgumentException tag (and added @param tags) on renameColumn, replaceColumn and removeColumn in 4037df1.
Contributor
Author
There was a problem hiding this comment.
Good point — done in 0440170. Converted _columnIndex's prose exception note into a proper @throws IllegalArgumentException tag and added a @param name tag, matching the public name-based methods.
CsvSchema.Builder (#699)
Member
|
Added in 2.x (for 2.23.0) and 3.x (3.3.0). |
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.
Fixes #699
CsvSchema.Builderonly lets you modify columns by index (renameColumn(int, ...),replaceColumn(int, ...),removeColumn(int)), so modifying a column by name meant building the schema, scanning for the index, and rebuilding — and the index could shift in between. This adds name-based overloads so the fluent builder can locate a column by name directly.Changes
renameColumn(String oldName, String newName)replaceColumn(String name, Column c)removeColumn(String name)Each resolves the name to an index via a new
_columnIndex(String)helper (linear scan, mirroring the existinghasColumn(String)) and delegates to the corresponding index-based method, so existing behavior is unchanged. An unknown name throwsIllegalArgumentException, consistent with the existing_checkIndexout-of-range handling.Test evidence
Added to
CsvSchemaTest:testModifyColumnsByName— rename/replace/remove by name preserve column positions and only touch the targeted column.testModifyUnknownColumnByName— an unknown name throwsIllegalArgumentException../mvnw -pl csv test -Dtest=CsvSchemaTest→Tests run: 11, Failures: 0, Errors: 0.Verification done: (1) no in-flight PR (searched open/all PRs for
CsvSchema renameColumn removeColumn); (2) no self-claim (issue has no comments); (3) code-focused (CsvSchema.java+ test); (4) confirmed the Builder had only index-based modifiers on2.x; (6) not aspring-projects/*repo, no triage gate.