Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi there,
I'm getting a NullPointerException when trying to calculate an expression in a tMap that has 2 inputs.
Here is the syntax of the expression:
Relational.ISNULL(account_transaction.date_entree) || Relational.ISNULL(account_transaction.date_sortie) ? null : TalendDate.diffDate(account_transaction.date_sortie, account_transaction.date_entree, "HH") <= 5 ? 0.0 : Relational.ISNULL(calcul_taxe_sejour.taxe_sejour) ? null : calcul_taxe_sejour.taxe_sejour
account_transaction is my Main and calcul_taxe_sejour is my Lookup.
The error is raised on this line of the expression:
: Relational.ISNULL(calcul_taxe_sejour.taxe_sejour)
but everything is correctly written for the Lookup flow and moreover the job compiles:
Also I set up the field as nullable.
I don't understand what the problem is. If anyone can suggest a few things I can try to debug that would be awesome.
Thx!
Can you please elaborate the entire tmap configuation with a screenshot ?
Thanks ,
Praveen M.
I suspect your issue is that the column you are passing the data to is not nullable. Your code looks OK, but it will enable a null output. In your output schema, check that the column is nullable.
I suspect that the error line is misleading here. Take a look at this mini tutorial (https://community.talend.com/t5/How-Tos-and-Best-Practices/How-to-debug-tMap-errors/m-p/40951#M9) on debugging tMap errors. This is a useful and relatively easy way of trapping issues like this.
OK so I just replaced the "null" in the last nested if with a numeric value and it works:
Relational.ISNULL(account_transaction.date_entree) || Relational.ISNULL(account_transaction.date_sortie) ? null : TalendDate.diffDate(account_transaction.date_sortie, account_transaction.date_entree, "HH") <= 5 ? 0.0 : Relational.ISNULL(calcul_taxe_sejour.taxe_sejour) ? -1.0 : calcul_taxe_sejour.taxe_sejour
Even if the output column is set as nullable since the beginning.
Now comes another question: how come the "null" in the first "if" does not trigger the same error? I checked and there are rows that satisfy the first condition and these were set to null...