Satya Pavan
Satya Pavan

Reputation: 314

Nifi put / append output of FetchHBaseRow back to the flowfile

I have a csv file with 10 fields. I need to lookup hbase to get a value corresponding to one of the csv fields. The resultant hbase field should be appended to the csv file. Using Nifi, I built the following flow.

GenerateFlowFile (create a csv record) --> UpdateRecord(configured avro schema name to read incoming csv file) --> ConvertRecord (configured CSV Reader & JSON writer) --> SplitJSON --> EvaluateJSONPath(to fetch the row key for hbase lookup) --> FetchHBaseRow (got the output as a flow-file attribute)

Now, the challenge is to read the contents of the attribute 'hbase.row' which is a JSON, pick one of the field-value pair, append it to the flow file content

Upvotes: 0

Views: 366

Answers (1)

Bryan Bende
Bryan Bende

Reputation: 18670

Expression Language has a jsonPath function:

https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#jsonpath

You should be able to use UpdateAttribute to create a new attribute that contains the extracted field, something like firstName = ${myJson:jsonPath('$.firstName')} would extract the value of firstName into an attribute called firstName, starting from the attribute myJson.

After that you should be able to use UpdateRecord to add the value into the flow file content, assuming your schema has a field for the value.

Upvotes: 1

Related Questions