[ 
https://issues.apache.org/jira/browse/NIFI-6303?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Koji Kawamura updated NIFI-6303:
--------------------------------
    Status: Patch Available  (was: Open)

Thanks for reporting the issue [~LAAA]. I was able to reproduce it with the 
attached template.

By debugging the behavior, I found this comes from how CSVRecordSetWriter 
determines output fields ordering with ValidateRecord.

ValidateRecord support extra fields, those are not defined in the validation 
target schema. When it writes output records, it uses special writing method 
called "writeRawRecord".

Currently, CSVRecordSetWriter generates output fields by merging 
record.getRawFieldNames and recordSchema.getFieldNames(). And 
MapRecord.getRawFieldNames returns existing keys in the values, which doesn't 
guarantee ordering.

A possible solution is changing the merging order, so that fields defined in 
the schema are written first, then extra ones. I've submitted a PR.

> ValidateRecord doesn't maintain column order for JSON and XML input
> -------------------------------------------------------------------
>
>                 Key: NIFI-6303
>                 URL: https://issues.apache.org/jira/browse/NIFI-6303
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Extensions
>    Affects Versions: 1.8.0
>            Reporter: Ludovic AUTAA
>            Assignee: Koji Kawamura
>            Priority: Major
>         Attachments: ValidateRecord_test_column_order_before_and_after.xml
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Hello 
> Using Nifi in the following workflow
> GenerateFlowFile -> ValidateRecord ( JSONReader/CSVWriter )
> Input column order: id, firstname, lastname
> Output column order: firstname, id, lastname
> Can anyone reproduce using attached template ?
> Regards



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to