Five Stars

tWriteJSONfield change execution order of the job

Hello

 

I found following strange behaviour of the tWriteJSONfield component. It change the order of the rows processing.

 

There is an XML file with 2 records, i.e. <fileName>aaa.pdf</fileName><fileName>bbb.jpg</fileName>. Without tWriteJSONfield, 2 rows are processed by all components consequentially:

 

Pasted image at 2017_12_23 07_33 PM.png

 

 

But when I add  tWriteJSONfield, both rows are processed first by components located before  tWriteJSONfield, and then both rows are processed by the rest of components:

 

Pasted image at 2017_12_23 07_33 PM (1).png

 

It is criticall in my case because I use global variables for each row. Why it behave such way? Is it as designed?


Pasted image at 2017_12_23 07_33 PM (1).png

Tags (1)
7 REPLIES
Moderator

Re: tWriteJSONfield change execution order of the job

Hello,

This should be the known component behaviour. such as, tAggregate and tDenormalize components may change input order.

What does your current use case look like?

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Five Stars

Re: tWriteJSONfield change execution order of the job

Hi Sabrina

 

First of all it is generally not a good thing when execution order is not transparent.

I faced this issue because I use global variable which I set for the row. I set global variable before tWriteJSONField component. And I need to get this variable after  tWriteJSONField component. And because of this behaviour, I can get value only for the last row.

Moderator

Re: tWriteJSONfield change execution order of the job

Hello,

Would you mind posting your current setting of global variable screenshot on forum so that we can see if there is any workaround for your scenario?

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Five Stars

Re: tWriteJSONfield change execution order of the job

Here it is:

 

1) generates 2 random rows

2) set random value to global variable

3) call tWriteJSON (doesnt really matter what it do)

4) get global variable value using tMap. The value is always same, the last one generated

 

talend2.JPG

 

tLogRow_5 displays only value for the last row

 

Capture2.JPG

 

Capture3.JPG

 

 

 

 

Five Stars

Re: tWriteJSONfield change execution order of the job

Hi Sabrina, any news on that? I found a workaround (using Java code) but I think this is an issue in Talend and should be fixed

Moderator

Re: tWriteJSONfield change execution order of the job

Hello,

So far, we don't have a better workaround on execution order issue. Feel free to create a jira issue on talend bug tracker.

https://jira.talendforge.org/secure/Dashboard.jspa

Best regards

Sabrina

 

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Community Manager

Re: tWriteJSONfield change execution order of the job

Hello
It seems like a bug, I tested and got the same issue.
Do you want to generate a json string for all input rows or a json string for each input row? If later, you can use tFlowToiterate to iterate each input row, eg:
tFileinputXML--main(row1)--tFlowToiterate--iterate-tfixedflowinput--main--tWriteJsonField--tMap-->tllogrow

on tFixedFlowInput or tMap, you can get the current value with the expression like:
(String)globalMap.get("row1.columnName")
//for string type.

Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business