Support Questions

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

How to capture number 0 in RouteOnAttribute

avatar
New Contributor

Hi,

 

I have a requirement where-in I have to take a count(*) using selecthiveQL and if count is 0 then I have to insert a row. 

My flow is selectHive QL → RouteOnAttribute where in I am trying to capture the 0 

Json is as below:

[ {
"_c0" : 0
} ]

can some one please tell me how to capture this zero, I tried multiple ways but not able to. 

Also if anyone has better solution pls let me know. This is quite urgent. 

1 ACCEPTED SOLUTION

avatar
Super Mentor

@vamcits 

 

You can use EvaluateJsonPath processor to extract the 0 from the json you shared

 

Screen Shot 2019-11-12 at 12.29.46 PM.png

You can name the custom property added above to whatever you like (I just used C0).
This will result in a "C0" attribute being generated on the FlowFile with a value of "[0]".

If you don't wan the square brackets around the number, you can remove them using an updateAttribute processor as follows:

Screen Shot 2019-11-12 at 12.34.09 PM.png

Then you can perform your routing with the RouteOnAttribute processor.

 

Hope this helps,
Matt

 

 

 

View solution in original post

1 REPLY 1

avatar
Super Mentor

@vamcits 

 

You can use EvaluateJsonPath processor to extract the 0 from the json you shared

 

Screen Shot 2019-11-12 at 12.29.46 PM.png

You can name the custom property added above to whatever you like (I just used C0).
This will result in a "C0" attribute being generated on the FlowFile with a value of "[0]".

If you don't wan the square brackets around the number, you can remove them using an updateAttribute processor as follows:

Screen Shot 2019-11-12 at 12.34.09 PM.png

Then you can perform your routing with the RouteOnAttribute processor.

 

Hope this helps,
Matt