Skip to main content
saquibsk
Gold ⭐️⭐️
March 2, 2024
Solved

Make a copy of columns and reanme it in NiFi processor

Hello Team,

 

I have one column and did some calculation on it and wanted to make another copy of same column to create flag to check whether records are empty or not and retain the same column also.I tired to using pulling another processor and  wrote calculation New_field , Old_column which did not work.

However, this approach did not yield the desired outcome.

saquibsk_0-1709381366837.png

 

saquibsk_2-1709381609308.png

saquibsk_1-1709381579480.png

 

 

SAMSAL
SAMSALAnswer
Platinum ⭐️⭐️⭐️
March 2, 2024

@saquibsk,

It seems you are using Literal Value  in the Replacement Value Strategy of the second UpdateRecord. I think it needs to be "Record Path Value" since you are referencing another field from the content data itself.

 

If that helps please accept solution.

Thanks

3 replies

SAMSAL
SAMSALAnswer
Platinum ⭐️⭐️⭐️
March 2, 2024

@saquibsk,

It seems you are using Literal Value  in the Replacement Value Strategy of the second UpdateRecord. I think it needs to be "Record Path Value" since you are referencing another field from the content data itself.

 

If that helps please accept solution.

Thanks

Translate
saquibsk
saquibskAuthor
Gold ⭐️⭐️
March 2, 2024

Thank you very much @SAMSAL . Do we need to provide the  JsonPath expressions ? I had simplifed data using JOLT Spec so I am getting flat JSON so below has worked.  What about if we have structured data ? 

Another Question: what if I wanted to write the calculation on column rather than filed.value ? something like below ?

saquibsk_1-1709390545624.png

 

 

Translate
Shakib M.
SAMSAL
Platinum ⭐️⭐️⭐️
March 2, 2024

Hi @saquibsk ,

The UpdateRecord processor uses the Nifi Record Path syntax to traverse record structure :

https://nifi.apache.org/docs/nifi-docs/html/record-path-guide.html

When your Replacement Value Strategy is set to Record Path Value then the path has to adhere to the record path syntax as explained in the link.  The record path allows you to update structured data even if you have more than one record in an array of records. Please see the documentation here as well for more help:

https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.7.1/org.apache.nifi.processors.standard.UpdateRecord/additionalDetails.html

If you are having more issues it would help to provide sample input and the expected output result alongside the relevant processors configuration screenshot. This will enable the community to help you better and resolve your issue faster.

If you find this is helpful please accept  solution.

Thanks

Translate