How to get count of rows filtered from expression filter in tmap

One Star

How to get count of rows filtered from expression filter in tmap

Hi,
I have a expression filter on the input file row in tmap to insert only not null values to the postgresql tables. How can I get the rows that are filtered by the expression filter.
So if in my file i have 10 records and there are 2 records that have a null value in the primary key, so when i run my job it loads only 8 records and rejects the 2 null records from the expression filter. how do i get this 2 rejected records count - here 2.

Any ideas?
One Star

Re: How to get count of rows filtered from expression filter in tmap

can you show the job structure...
see attached img to get an idea. if you know Java this will make your task easy.
the globalMap.get("count"); will give you the count of the output rowa came into that tJavaRow_3
One Star

Re: How to get count of rows filtered from expression filter in tmap

Hi,
thank you for the reply. I have uploaded the job structure. In the image if you see the number of rows before the tmap2 is 16 and after the tmap is 15, which means the tmap expression filter has filtered one row. I want the count of this rows filtered. How to get that?
One Star

Re: How to get count of rows filtered from expression filter in tmap

Uploading the image.
One Star

Re: How to get count of rows filtered from expression filter in tmap

I think you mean to tMap1, there I can see 16 rows input and 15 rows output, and where you want to update the count?
One Star

Re: How to get count of rows filtered from expression filter in tmap

after tUniqRow you can put the tJava2 Component and after tMap and before tFlometer_8( or Supplier_metadata) you can place the tJavaRow_3 component from my sample.
the following code will give you the error count after tJavaRow_3
(Integer)globalMap.get("tUniqRow_1_NB_UNIQUES") - new Integer(globalMap.get("count").toString()).intValue()
One Star

Re: How to get count of rows filtered from expression filter in tmap

Thank you for the update.
Yes, I meant tmap_1.
I want the value to update one of the stats table using the tmap2.
So if i want to update the value in the stats table in tmap2, can i use the expression (Integer)globalMap.get("tUniqRow_1_NB_UNIQUES") - new Integer(globalMap.get("count").toString()).intValue() directly on the column?

I will give it a try using your sample.
One Star

Re: How to get count of rows filtered from expression filter in tmap

Yes, use the same expression in tMap2 Column. it should work
One Star

Re: How to get count of rows filtered from expression filter in tmap

I added thetjavarow between tuniqrow and tmap and another one between tmap_1 and tflowmeter_10 and added the below code for tjavarow1 and tjavarow2
tjavarow1:
globalMap.put("count", 1);
tjavarow2:
globalMap.put("count", (new Integer (globalMap.get("count").toString()).intValue())+1);

And added the below code for the column in the tmap2
((Integer)globalMap.get("tUniqRow_1_NB_UNIQUES") - new Integer(globalMap.get("count").toString()).intValue())

I get the below error
Exception in thread "main" java.lang.Error: java.lang.Error: Unresolved compilation problems:
Duplicate local variable tos_count_tJavaRow_1
Duplicate local variable nb_line_tJavaRow_1
at test.asda_game_import_0_1.ASDA_Game_Import.tPostgresqlConnection_1Process(ASDA_Game_Import.java:18891)
at test.asda_game_import_0_1.ASDA_Game_Import.runJobInTOS(ASDA_Game_Import.java:21783)
at test.asda_game_import_0_1.ASDA_Game_Import.main(ASDA_Game_Import.java:21635)
Caused by: java.lang.Error: Unresolved compilation problems:
Duplicate local variable tos_count_tJavaRow_1
Duplicate local variable nb_line_tJavaRow_1
Am I missing something here?
One Star

Re: How to get count of rows filtered from expression filter in tmap

click on "Code" view, and check where you are getting the compilation error. and try to correct that one.
I thought you will add tJava component. if you you use tJavaRow between flowmeter and tMap then you need to cllick on generate code,. and then at the end you can add
globalMap.put("count", 1);

then you need to reMap in your tMap component(check your tMap).