Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have two input columns one is Organization and the other is Name.
I have a separate output column with the field Type. If Organization is populated then the Name field is not going to be populated and the other way around. So I need String Method that will populate a column with either "OR" if Organization Input Field is populated or "IN" if Name field is populated.
(IS NOT NULL).equalsIgnoreCase(row1.Name) && (IS NOT NULL).equalsIgnoreCase(row1.Organziation) ? "OR" : "IN"
Not sure if there is a IS NOT NULL function in JAVA. I would need to handle NULLS in this syntax as well
Please advise
Andrew
Hi @sm
Empty string is different from null in Java. So why don't you check some of the old Talend posts which has handled this scenario.
For example, the below one. You need to do an OR clause for empty string at same level as NULL.
Warm Regards,
Nikhil Thampi
Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Hi,
equals compare strings values
like name = "IS NOT NULL"
in case where you need check NULL it could be like:
row1.Name!=null && row1.Organziation!=null ? "OR" : "IN"
or
row1.Name==null || row1.Organziation==null ? "IN" : "OR"
Hi Andrew,
A slight Modification I could think is as below.
If both input values are null, output wll be null in this case.
Relational.ISNULL(row1.Organziation) && Relational.ISNULL(row1.Name) ? null :(!Relational.ISNULL(row1.Organziation) && Relational.ISNULL(row1.Name) ?"OR":"IN")
If you don't want to check above condition, you can take second part of the logic assuming only one of them will be populated at a time.
!Relational.ISNULL(row1.Organziation) && Relational.ISNULL(row1.Name) ?"OR":"IN"
Warm Regards,
Nikhil Thampi
Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Hey @nthampi
I'm getting "IN" value for all values in my output column. With trying both of your String Methods
I even tested it with a tFixedFlowInput and tLogRow and still got the same Output. So if the Organization Input column is populated then the First Name field will be blank and not NULL. This may change the syntax around. It's the same the other way around if First Name is populated then the Organization Input Column will be Blank and not NULL.
See SS below
Hi @sm
Empty string is different from null in Java. So why don't you check some of the old Talend posts which has handled this scenario.
For example, the below one. You need to do an OR clause for empty string at same level as NULL.
Warm Regards,
Nikhil Thampi
Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Hi Andrew,
I hope you were able to resolve the issue from the above details. Could you please mark the topic as resolved since you have all the necessary details for your original query of the post? It will help other Talend members during their reference.
Warm Regards,
Nikhil Thampi
Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂