Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How to capture number 0 in RouteOnAttribute

Solved Go to solution

How to capture number 0 in RouteOnAttribute

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

Accepted Solutions
Highlighted

Re: How to capture number 0 in RouteOnAttribute

Master Guru

@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

 

 

 

1 REPLY 1
Highlighted

Re: How to capture number 0 in RouteOnAttribute

Master Guru

@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

 

 

 

Don't have an account?
Coming from Hortonworks? Activate your account here