Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
schwarben
Contributor
Contributor

'null' values received when using a tJavaFlex with a main flow. Fixed by using an iterate flow.

I still experience troubles using tJavaFlex component. Using a main flow as an input, sometimes everything runs smoothly but there are cases when the tJavaFlex only gets null values in all fields. I managed to find a workaround by using a tFlowToIterate component to transcode the main flow in an iterate flow, but I would like to understand what is happening here.

  • Why is tJavaFlex sometimes ok with main flows, and why sometimes it gets only null values ?
  • Why using an iterate flow helps ?
  • And finaly, I realized I don't really get what an iterate flow does and when to use it compared to a main flow.

Any explanation on any of these topics would be greatly appreciated.

Thanks !

Labels (2)
1 Solution

Accepted Solutions
gjeremy1617088143

for the tJavaflex i think it's because you use the for clause in the begining and not in the loop, the beginning is launched at first and then it loop for each iteration of the main row in the main part of the tJavaflex.Thats why it's working with tflowtoiterate.

View solution in original post

14 Replies
gjeremy1617088143

Hi, why are you using tJavaFlex ?

Could you send screens of the tJavaFlex ?

and also screens of the tFixedFlowinput.

Send me Love and Kudos

gjeremy1617088143

flow to iterate will execute the rest of the subjob after the iterate link for one iteration of the main flow, so if you have 3 rows in the main flow it will execute the rest 3 times (one for each row of the main flow). It can also stock in globalVar the value of the fields of one row. So you can reuse them at each moment of the iteration.

schwarben
Contributor
Contributor
Author

Hello Jeremy, and thanks for your interest.

 

I typically use a tJavaFlex when I need to "insert" lines in a flow. This can happen in various cases.

In the toy exemple above I have a flow with three String fields (N, P, T). The last field contains a coma separated list of tokens and I want a new line for each token : (N, P, S) where N an P are simply repeated and S contains the token extracted from T.

 

So, a stream composed of these two lines :

[("x", "y", "0"), ("a" ,"b" , "1,2,3")]

 

Would result in 4 lines :

[("x","y","0"), ("a","b","1"), ("a","b","2"), ("a","b","3")]

 

The code seems straightforward, tell me if I misunderstood something.

0695b00000F7iO1AAJ.png

gjeremy1617088143

ok just use the tNormalize component , you don't have to use a tJavaflex for this.

tAggegateRow -->main-->tNormalize-->main -->the rest of the job

Send me Love and Kudos

schwarben
Contributor
Contributor
Author

Makes perfect sense. Thanks.

Actually, everythink became clear when my last component in the subjob was a file writer. With an iterate, unless I specifically ask for an appending behaviour, the file is overwritten at each iteration.

schwarben
Contributor
Contributor
Author

Thanks for pointing out the tNormalize, I actually didn't know that component.

 

That being said in my today's job, while I need to "normalizie" a column I also need to mute others. Let's say each line contains shopping informations such as the id of the buyer, total shopping price and the coma separated list of purchased items. Even though I don't have the detailed price for each item I need to render a line per item, but when doing so I would like to keep the other fields only on the first line and mute them for the remainig lines.

 

("bob", "10$", "cake,tea")

-->

("bob", "10$", "cake")

(, , "tea")

 

tJavaFlex still seems a natural way to perform that.

 

Furtermore, last time I used a tJavaFlex I had to deal with something a bit more tricky where a part of the job was about storing manager related information in a HashMap, and the other part of the job was about running through this HashMap to extract and list this "per-manager" information. To date I still can't see any other way to do that than using a tJavaFlex.

schwarben
Contributor
Contributor
Author

All that aside, do you have any idea if an explanation to why tJavaFlex would read null values from a main flow ? I can provide a toy example if needed.

gjeremy1617088143

for the tJavaflex i think it's because you use the for clause in the begining and not in the loop, the beginning is launched at first and then it loop for each iteration of the main row in the main part of the tJavaflex.Thats why it's working with tflowtoiterate.

gjeremy1617088143

you could use tnormalize to separate the values then add an order number with a sequence by exemple and then set to null each values for N and P if order is different to 1.