cancel
Showing results for 
Search instead for 
Did you mean: 

Check Value In UDF

former_member192105
Participant
0 Kudos

Hi,

I am using a UDF to take substring of my value from source (source value is of format abcd/xyz). Now I want to check if there exists any value before "/" i.e. I want to check if there is any value before "/" . I tried using the .length function, but due to some reason I am not able to get it working. So please tell me how to get the below UDF working:

public String getUser1Id(String Id, Container container) throws StreamTransformationException{

String logName = Id;

int len = logName.indexOf("/");

logName = logName.substring(0,len);

return logName;

Id is the input from the source (abcd/xyz) into the UDF.

Thanks.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

your code is working if you have "/" in your ld parameter. Another point is your function returns left of '/' in your input. Is this your requirement or returning true or false depending on the existence of anything before '/'?

Kind Regards,

former_member192105
Participant
0 Kudos

If the input value is abcd/xyz, the UDF returns abcd. I had to check if abcd exists or not; to check this you need to use the .length function.

former_member192105
Participant
0 Kudos

Got the UDF working. Used logName.length()!=0;