Support Questions

Find answers, ask questions, and share your expertise

Problem with update attribute in NIFI

avatar
Contributor

 

hello, 
I have the following problem -
I have a flow and I have a name attribute in it, I need to change it to uppercase.
I used UpdateAtribute processor for this, as property I have name and as vaule I have:${name:toUpper()}
unfortunately it doesn't work and now instead of having name in capital letters I have Empty string set, anyone know why this is happening?
 


 
 
 
 
 

 

 

 

1 ACCEPTED SOLUTION

avatar
Expert Contributor

Hello,

 

could you please check right before UpdateAttribute Processor, if the attribute "name" is filled with your expected content?

Normally it is correct what you explain - maybe you loose somewhere after merge, wait/notify, ... your attribute.

 

Greetings

View solution in original post

2 REPLIES 2

avatar
Expert Contributor

Hello,

 

could you please check right before UpdateAttribute Processor, if the attribute "name" is filled with your expected content?

Normally it is correct what you explain - maybe you loose somewhere after merge, wait/notify, ... your attribute.

 

Greetings

avatar
Master Mentor

@MWM 

Your description is not super clear to me.
FlowFile Attributes are in format of <attribute name>=<attribute value>
example key=value FlowFile attributes:

Attribute name = Attribute value
name=toyota
type=car


Here is how I interpret what you have provided:
- You have a FlowFile that has a custom FlowFile "Attribute Name" on it "name".
- That "name" Attribute has no value associated to it. (name = )

The UpdateAttribute processor allows you to add new key=value (attribute name = attribute value) attribute pairs to an existing FlowFile or modify the value of an existing FlowFile Attribute Name.
You can NOT create a new attribute and then modify or use that new attribute within the same processor in which it was created.

Lets say you have a FlowFile with the example FlowFile attributes and values I shared above.
Then you use the UpdateAttribute processor to change the value on the Attribute "name" to all uppercase.
The NiFi Expression Language (NEL) statement you created:

${name:toUpper()}

will take the subject "name" and return it's value "toyota".  That returned value is passed to the toUpper() NEL function which converts the it to Uppercase "TOYOTA".  The resulting value is then written to the FlowFile attribute defined in the UpdateAttribute processor. Assuming an UpdateAttribute processor configured as below:

MattWho_0-1689168412724.png

The NEL expression resulting a new value of "TOYOTA" would be written to the FlowFile Attribute "name" since "name" already exists as an attribute on the FlowFile, its current attribute value of "toyota" would be replaced with new value "TOYOTA".

Hope this helps clarify how NiFi FlowFile Attributes and the UpdateAttribute processor is used.

If you found that the provided solution(s) assisted you with your query, please take a moment to login and click Accept as Solution below each response that helped.

Thank you,

Matt