Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
We are using tMap for the following:
1. We are joining source and target table on key columns source.id= target.id
2. We are using globalMap to store the name of some columns for both the source and target.
3. Global Map contains the following values:
source_hash_column > hash_key
3. We want to use the column name stored in the globalmap, in the Filter Expression of tMap output.
(source.((String)(globalMap.get("hash_key")) == null)
4. Now issues are:
a) If we use it the way mentioned in point 3, it gives compilation error: Syntax error on token ".", Identifier expected after this token.
b) If we use concatenation like below, then its treating column names itself as String and Not the actual value stored in that column.
(source + "." + ((String)(globalMap.get("hash_key")) == null)
Can someone please suggest, how can we use globalMap's column name's values in tMap Filter Expression?
@Deepti Hazari ,here is the job attached.
Please like and select as best the correct replay.
Thanks,
Manohar
@Deepti Hazari , can you show your job design where are you setting a global variables and read it?
Thanks,
Manohar
Thanks @Manohar B for your reply. Here is a detailed explanation with the snapshot.
Since I can't share the confidential Project Design, here is sample example to replicate the issue.
In this snapshot, there are :
a) 2 inputs row1 and row2 for tMap
b) a left join between them.
c) tMap join output"out1" with filter expression where target key column is null.
d) globalMap is already populated with the values : "source_key_column" >> EMP_ID and "target_key_column" >> EMP_ID.
Now, in usual case, to achieve this, we would have just dragged the key column from row2 to the expression filter with null check such as
row2.EMP_ID == null
But, we are trying to parameterize the column name "EMP_ID" here by substituting it from globalMap. Now there are 2 options here:
1. If we are using it as below, it is throwing compilation error "it gives compilation error: Syntax error on token ".", Identifier expected after this token."
row2.globalMap.get("target_key_column") == null
2. If we are using it as below, then it is actually comparing the String value "row2.EMP_ID" and not the value stored within the EMP_ID column of row2.
row2 + "." + globalMap.get("target_key_column") == null
so please suggest, how should I use the parameterized column name in the tMap filter expression?
@Deepti Hazari ,Where are you put that variable in global map? since your getting the variable in tMap
.
@Manohar B before this tmap, I'm using tJavaRow to populate the values in globalMap.
@Deepti Hazari ,in tJavarow you can print that global variable and check what are you getting?
@Manohar B , I have already tried that and I am getting the correct value "EMP_ID" when I print globalMap.get("target_key_column"), but he problem is that when I am using it with row2.globalMap.get("target_key_column") in the Filter expression , then it is not treating it the same way as it would treat row2.EMP_ID.
@Deepti Hazari , When you have multiple records you need to iterate record by record using tFlowtoIterate.
@Deepti Hazari ,And one more thing that when you put you need to use the below way right.
((String)globalMap.put("myObject", row2.col)
((String) globalMap.get("myObject"))
ok @Manohar B . I will try this option of having "row2" concatenated while putting the value in the globalMap itself