cancel
Showing results for 
Search instead for 
Did you mean: 

Unwanted null values in UDF

0 Kudos

I am facing a strange situation in one of my mapping programs.

The graphical mapping looks like this:

When I do a display queue of the FIRST udf I can see the expected result

When I do a display queue in the next UDF which is taking the output of the FIRST UDF I can see some extra "null" values

In the subsequent UDF I see that all the output values are vanished and some "null" values are getting as an input to the target function

With this strange behaviour my mapping is failing and I am unable to understand how my output values are getting replaced with "null"

Any help will be appreciated

Sourabh

Accepted Solutions (1)

Accepted Solutions (1)

vinaymittal
Contributor
0 Kudos

Can you try using CollapseContext and then splitbyvalue before the Handlecontext udf it will remove the null values but here we should focus on the reason why the null values are coming..in the DQ of second udf can you provide the code not all of it but the code associated with poppulating the ResultList variable. It has something to do with the Duplicate udf

0 Kudos

Hi Vinay

That was a valid point to try figuring out why the null values were coming so i went back in the mapping logic to find anything and the team noticed something

we have used ifS at many places instead of if

So we replaced all the ifS with if

And all the null values disappeared

When we looked into the difference between the two we found that the explanation is following:

when one of the branches of function 'if' contains a User-Defined function that produces side-effects. Like increments and stores a counter in 'GlobalContainer', for example. Such functions will be executed more times than before and will cause the numbering to go awry.

As replacing if with ifS has solved the issue I wonder that above scenarios was occuring in our case.

Thanks all for your help.

vinaymittal
Contributor
0 Kudos

I remember facing the same issue its irritating and very cryptic and sometimes on such issues we end up spending days good to know you figured it out.

always make it a point to not to use IFS and go for IF unless you think that second condition also needs to be evaluated.

Answers (3)

Answers (3)

pvishnuvardan_reddy
Active Contributor
0 Kudos

HI Sourabh,

Can you please cross check/share the code snippet of the Duplicate UDF to make sure this issue is not occurring because of the the code.

Also, what is the udf type of the handle context udf, is it context or queue?

Regards

praveen_sutra
Active Contributor
0 Kudos

Hello Sourabh,

Hope this helps,

thanks and regards,

Praveen T

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Sourabh,

Can you try adding mapWithDefault after all the ResultLists of the Duplicate UDF?

Regards,

Mark