Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Duplicate
-
1.4.0, 1.5.0
-
None
-
None
-
None
Description
If you have ValidateRecord configured with a CSV reader and CSV writer and send in some valid data, the flow file is routed to "valid", but the columns are written out in a different order than there were read.
This means if the next processor is another record-oriented processor using the exact same schema and reader, it will fail to read it because the first column won't be what it expects.
From doing some digging, it appears that in WriteCsvResult there is a method getFieldNames() that does this:
final Set<String> allFields = new LinkedHashSet<>(); allFields.addAll(record.getRawFieldNames()); allFields.addAll(recordSchema.getFieldNames());
In this case, record.getRawFieldNames() is coming from the keyset of a HashMap which means it is not maintaining the order the fields were read in.
CsvRecordReader line 97:
final Map<String, Object> values = new HashMap<>(recordFields.size() * 2);
Attachments
Issue Links
- is part of
-
NIFI-4955 ValidateRecord does not preserve columns ordering with CSV
- Resolved