Skip to main content
brajeshreddy
Gold ⭐️
July 21, 2023
Question

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

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

joseomjr
Gold ⭐️⭐️
September 16, 2023

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...

Translate
joseomjr
Gold ⭐️⭐️
September 18, 2023

Forgot the ";" in the replacement value

 

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

 

Translate