问题
This question is related to this SO question
Above solution solved my problem, Now I tried to connect this into a flow coming from QueryRecord
processor.
Here this QueryRecord
divide my flowfile into two streams. Lets say customers
and suppliers
. And ExecuteGroovyScript
is used to add ORDER
and COMPLAINT
.
Sample csv :
id,record_type
1,0
2,0
3,1
So result should be :
id,record_type
1,ORDER
2,ORDER
3,COMPLAINT
Actual result just placed default 'IGNORE'
value.
QueryRecord
configurations
QueryRecord
csv write schema.
回答1:
If you just want to update the field value simply, then use UpdateRecord
processor.
When you input the text as follows:
id,record_type
1,0
2,0
3,1
then setting the record reader to CSVReader
with the option Schema Access Strategy
to the Use String Fields From Header
. The writer is not a concern. The UpdateRecord
processor properties look like this:
Record Reader CSVReader
Record Writer CSVRecordSetWriter
Replacement Value Strategy Literal Value
/record_type ${field.value:replace('0','ORDER'):replace('1','COMPLAINT')}
This will give your expected result.
来源:https://stackoverflow.com/questions/58910020/update-csv-value-using-executescript-processor-fails-in-apache-nifi-using-groovy