One Star

[resolved] tMap count number of matches in lookup table

Hi,
Is there anyway to count the number of matched rows in a lookup? Without having to use a t****row component and execute a count(*) query?
Thanks!
8 REPLIES
Community Manager

Re: [resolved] tMap count number of matches in lookup table

Hi
Your question is not clear, do you want to count the number of matched rows after join or count the number of rows queried from the lookup table? Can you please explain it with more details?
Thanks!
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] tMap count number of matches in lookup table

@shong;
I want to count the number of matched rows after the join.
Thanks!
Community Manager

Re: [resolved] tMap count number of matches in lookup table

Hi
Link the tMap output to a tJavaFlex component, and you can define a counter on tJavaFlex, for example:
...tmap--out1--tJavaFlex
on tJavaFlex:
in the begin part, define a counter:
int nb_line=0;
in the main part:
i++;
in the end part, store the counter to a global variable or context variable for used later:
globalMap.put("the_total_number_of_matched_rows", counter);
//or context.counter=counter;
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Four Stars

Re: [resolved] tMap count number of matches in lookup table

Hi mclarenlife,
There is a work around inside the tMap itself
- try using dummy column match_count for your inner join output
- inside this put system variable sequence generator....
This way you will get the total count of matched rows after inner join in your tMap. I hope you got an idea for implementation.
Vaibhav
One Star

Re: [resolved] tMap count number of matches in lookup table

@sanvaibhav, could you elaborate a little more on your solution. It sounds very promising!
Thanks!
Four Stars

Re: [resolved] tMap count number of matches in lookup table

Hi,
Use InnerJoin in Tmap input for your input columns and use something similar in new column in output
(Integer)globalMap.put("cnt",(Integer)Numeric.sequence("inner_join_cnt",1,1))
This will create numeric sequence "Inner_join_cnt" and put its value runtime inside "cnt" variable. You can use this variable after onSubJobOk...
I hope you got an idea.
Vaibhav
One Star

Re: [resolved] tMap count number of matches in lookup table

I'm using an OracleInput into a tmap and the datatype shows that it's a BigDecimal in the tmap when in the OracleInput it's a NUMBER(20,0). This value will need to be matched to a string at some point so I want to convert it to a string. I've tried using intValueExact() to an int and then use CHAR to convert to a string but that doesn't seem to work in this case.
Seventeen Stars

Re: [resolved] tMap count number of matches in lookup table

hi all,
You also  use the globalMap variable of the output flow or monitore the flow to get infos in tflowmetercatcher.
regards
laurent