- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Parse and modify data befor calling PutDatabaseRecord
- Labels:
-
Apache NiFi
Created ‎08-18-2017 07:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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,
Created ‎08-22-2017 01:24 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Created ‎08-18-2017 09:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Created ‎08-22-2017 10:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Created ‎08-22-2017 01:24 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Created ‎08-22-2017 02:22 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That works, i now have two new attributes. how can i add them to my flowfile content?
Created ‎08-22-2017 04:46 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use the ReplaceText processor. Use ${attribute_name} to write an attribute in your text.
