Support Questions
Find answers, ask questions, and share your expertise
Announcements
Check out our newest addition to the community, the Cloudera Innovation Accelerator group hub.

Parse and modify data befor calling PutDatabaseRecord

Explorer

Hi,

I've just started with nifi and am very new to its workings. I'm using version 1.3.0

I have a flow where i read some data from a microsoft sql db table using ExecuteSQL and then have PutDatabaseRecrod processor insert it into a mysql database. It works straight out of the box.

Before the PutDatabaseRecord i need to parse (regexp) value of a column, and create new fields.

I would appreciate if someone can hint out as to what processor to use here.

Thanks & regards,

1 ACCEPTED SOLUTION

With the UpdateAttribute, you can add your own property. (With the '+' button in the 'Properties' tab)

Add a property with the name : Sis_Grp.Dom and the value : ${ZComponent:substringAfter('"'):substringBefore('"')}

(the argument for the substringBefore is double quote between simple quotes.)

and a second with the name : Name and the value : ${ZComponent:substringAfter('Name="'):substringBefore('"')}

You can find all the Nifi Expression language here

View solution in original post

5 REPLIES 5

Hi

A common flow to modify your data is : ConvertAvroToJson -> splitJson -> EvaluateJsonPath -> UpdateAttribute

So you will have one flowfile by row and with the EvaluateJsonPath you convert your fields as attributes of this flowfile. After that you can use UpdateAttribute to modify an attribute or add new one. You can use Nifi Expression Language.

Explorer

Thanks Quentin, it works but i couldn't figure out the UpdateAttribute part. Using EvaluateJsonPath creates the attribute (

ZComponent) with a value

Sis_Grp.Dom="LOCAPPLE",Name="CrashGuard"

I now need to parse this value into seperate attributes. how can i achieved this with updateattribute

Sis_Grp.Dom=LOCAPPLE and Name=CrashGuard

With the UpdateAttribute, you can add your own property. (With the '+' button in the 'Properties' tab)

Add a property with the name : Sis_Grp.Dom and the value : ${ZComponent:substringAfter('"'):substringBefore('"')}

(the argument for the substringBefore is double quote between simple quotes.)

and a second with the name : Name and the value : ${ZComponent:substringAfter('Name="'):substringBefore('"')}

You can find all the Nifi Expression language here

Explorer

That works, i now have two new attributes. how can i add them to my flowfile content?

You can use the ReplaceText processor. Use ${attribute_name} to write an attribute in your text.