Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] getting null value in globalMap key talend 5.2v

Hi,
I have scenario to load data based on column "Company" value. i.e. if Company value is "ABC" then output row will insert in that Abc.txt file as delimiter "|" . and if "ABC.txt" file not exist then it would create new and load data into it. if value in company field will change new file with that value (company) should create and load that row into that destination file.
refer image 3 for source data schema,

I have prepared data flow, please find it in attachment. using tsetglobalvar I am assigning company value to global variable and using this variable value for destination file creation. (see image 1 and 2)
using tJavaRow for debugging the global variable value up to tjavaRow it works properly but issue comes in tFileOutput destination, it shows "null" for global variable "cmpy".
Could any one please give the reason why it shows null?
Thanks in advance!!
0683p000009ME5j.png 0683p000009MEI5.png 0683p000009MEH8.png
Labels (3)
1 Solution

Accepted Solutions
alevy
Specialist
Specialist

Why would you need tFilterRow to filter other companies' data? Using tFlowToIterate allows you to send each flow to the correct file.
Yes, it will iterate as many times as you have rows in the source but that is what you have to do to use information from the data flow to determine the destination of that flow when you don't know all the possible destinations when you design the job.
You could design the job as follows instead:
tInput ("select distinct company from ")
--tFlowToIterate-->
tInput ("select * from table where company='"+globalMap.get("row1.Company")+"'")
--> tMap --> tFileOutputDelimited

View solution in original post

5 Replies
alevy
Specialist
Specialist

You need to use tFlowToIterate. Please see many existing posts on the forum on how to do this.
Anonymous
Not applicable
Author

Hi Alevy,
Thanks for the reply, if I use tFlowToIterate then I have to use another component "tFilterRow" to filter data of other companies. and also suppose I am having 1000 companies then this need to iterate thousand times. this is unnecessarily burden, and causes performance impact.
Thanks
alevy
Specialist
Specialist

Why would you need tFilterRow to filter other companies' data? Using tFlowToIterate allows you to send each flow to the correct file.
Yes, it will iterate as many times as you have rows in the source but that is what you have to do to use information from the data flow to determine the destination of that flow when you don't know all the possible destinations when you design the job.
You could design the job as follows instead:
tInput ("select distinct company from ")
--tFlowToIterate-->
tInput ("select * from table where company='"+globalMap.get("row1.Company")+"'")
--> tMap --> tFileOutputDelimited
Anonymous
Not applicable
Author

Hi Alevy,
Thanks, its working fine, but I have one further query, In the example I have mentioned, "using tJavaRow for debugging the global variable value up to tjavaRow it works properly but issue comes in tFileOutput destination, it shows "null" for global variable "cmpy"."
Could you give me reason why we can not use "cmpy" as global variable in tOutputDelimieted?
Thanks in advance!
alevy
Specialist
Specialist

Because the output destination is initialised before the input starts to be read so the variable is not populated. Otherwise the file would have to be opened and closed for each row, which is not usually necessary and where using tFlowToIterate comes in. tJavaRow, on the other hand, is executed as part of the flow.