-
-
Notifications
You must be signed in to change notification settings - Fork 151
Open
Labels
csvneed-test-caseFurther progress requires inclusion of problem reproduction, ideally test caseFurther progress requires inclusion of problem reproduction, ideally test case
Description
The CSV feature CsvParser.Feature.FAIL_ON_MISSING_COLUMNS
does not work as expected when using a typed CsvSchema with withColumnReordering(true)
. If a column appears in the POJO, but not in the file, no failure occurs. This seems to be due to the withColumnReordering(true)
completely rebuilding the columns, but the FAIL_ON_MISSING_COLUMNS
check only occurs during reading of individual rows of data, and it only checks against the rebuilt columns (from the file header, not against the POJO's columns).
Relevant lines:
- Check of reordersColumns: https://github.com/FasterXML/jackson-dataformats-text/blob/2.13/csv/src/main/java/com/fasterxml/jackson/dataformat/csv/CsvParser.java#L787
- If reordersColumns is true, we jump to here and fully rebuild the columns: https://github.com/FasterXML/jackson-dataformats-text/blob/2.13/csv/src/main/java/com/fasterxml/jackson/dataformat/csv/CsvParser.java#L818
- Somewhere around here is probably the best place to check the rebuilt schema columns against the original schema columns, if FAIL_ON_MISSING_COLUMNS is enabled: https://github.com/FasterXML/jackson-dataformats-text/blob/2.13/csv/src/main/java/com/fasterxml/jackson/dataformat/csv/CsvParser.java#L850
- This seems to be the only place we check for missing columns right now: https://github.com/FasterXML/jackson-dataformats-text/blob/2.13/csv/src/main/java/com/fasterxml/jackson/dataformat/csv/CsvParser.java#L924-L925
bjmi and matt-snider
Metadata
Metadata
Assignees
Labels
csvneed-test-caseFurther progress requires inclusion of problem reproduction, ideally test caseFurther progress requires inclusion of problem reproduction, ideally test case