Created on 03-02-2018 07:05 PM - edited 08-17-2019 05:20 PM
I am attempting to update an attribute based on incoming properties. Essentially I need to evaluate many incoming attributes and output a list in a new attribute based on the incoming attributes.
Here is an example:
The logic is IF attribute1="T" THEN ResultingAttribute="foo,"
IF attribute2="T" THEN ResultingAttribute="bar,"
IF attribute1="T"&&attribute2="T" THEN ResultingAttribute="foo,bar,"
Does anyone know how this can be accomplished using only 1 UpdateAttribute processor?
Created on 03-02-2018 09:07 PM - edited 08-17-2019 05:19 PM
Yes you can do that using Advance Usage,Change FlowFile Policy to use original.
Rule1:-
Conditions:-
${attribute1:equals("T")}
Actions:-
Attribute:-
ResultingAttribute
value:-
foo
Rule2:-
Conditions:-
${attribute2:equals("T")}
Actions:-
Attribute:-
ResultingAttribute
value:-
foo
Rule3:-
Conditions:-
${attribute1:equals("T"):and(${attribute2:equals("T")})}
Actions:-
Attribute:-
ResultingAttribute
value:-
foo,bar
These rules will be evaluated in the order they placed i.e rule1 is checked first then rule2 is checked second rule3 checked third.
you can rearrange order of evaluation by click and drag.
Let us know if you having any issues..!!
Created 03-05-2018 04:35 PM
Thank you for your response. It certainly works for the simplified example I provided, but in my application it could be checking for more than 2 incoming attributes. As of now it would check for 5 attributes, and it would not be possible to add a rule for each possible combination of attributes flagged with "T."
Created 03-06-2018 04:46 AM
If you feel like it will not possible to keep all combinations then other options to acheive this use case would be:
Write a script(in java,groovy..etc) and check all the combinations, write the required attributes to the flowfile.
Refer to below link for scripting cook books:-
https://community.hortonworks.com/articles/75032/executescript-cookbook-part-1.html
(or)
By using Hive query:
store the data into HDFS then feed the PutHDFS processor success relation to selectHiveQL processor then run your logic by using SQL query with case statement in it then extract your required attributes from the flowfile contents.