09-27-2021 01:05 AM
Here is the scenario:
I want to apply default value to a table, and the column(s) which need to apply default value might be changed. What I am doing is to:
$.hasOwnProperty('input1_COUNTRYCODE')?$input1_COUNTRYCODE: $COUNTRYCODE
to apply the default value for [COUNTRYCODE] column.My question is, if there is 100 columns in the source table, I need to create 100 hasOwnProperty in the mapper and if the column names in the source table changed I have to modify those expressions, so, is it any expression could get the field names dynamic to replace this COUNTRYCODE in the expression?
Source table:
[
{
"BANKNAME": "Test Bank 001",
"BANKNUMBER": "Test123",
"COUNTRYCODE": "US01"
},
{
"BANKNAME": "Test Bank 002",
"BANKNUMBER": "Test456",
"COUNTRYCODE": "US02"
}
]
Parameter file (default value):
"COUNTRYCODE":"US"
09-27-2021 01:35 AM
Hey @Dai9210,
Here’s one solution for you:
Default Values_2021_09_27.slp (8.6 KB)
The pipeline sends all records in an array. That array is joined with the default values 1=1. Right after, follows a mapper with expression that maps the $group array, and within that map, there’s a nested .mapValues() function that checks if the key is in the incoming document (apart from the $group). If it is map Its value, if not , keep the actual one. After the mapping is done, jsonSplitter will split the $group.
Regards,
Bojan
09-27-2021 02:31 AM
It works!
Thanks very much! @bojanvelevski