Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

How to replace/add some text for a matching patter in Nifi

avatar
Contributor

Hi,

 

Is there any processor to add some text/characters to each line in the flowfile in Nifi. Replace text seems to be more complicated given that the partiton value keeps changing.

 

compute incremental stats mydb.mytable partition (date=2023-07-21);

compute incremental stats mydb.mytable partition (name=abc);

to

compute incremental stats mydb.mytable partition (date='2023-07-21');

compute incremental stats mydb.mytable partition (name='abc');

 

Note: date=2023-07-21 comes as a complete string from the sys.partitions.part_name table in hive. We will need to add '' to the date.

2 REPLIES 2

avatar
Super Collaborator

ReplaceText processor should work..

This RegEx search pattern should do the trick:

^(.*?)\(([^=]*)=([^\)]*)\);$

With this replacement value:

$1($2='$3')

Don't forget to set the evaluation mode to line-by-line...

avatar
Super Collaborator

Forgot the ";" in the replacement value

 

$1($2='$3');