05-25-2022 07:20 AM
Hi Team,
Can we prefix/suffix multiple field names in mapping table expressions under mapper snap in a single shot?
As per the above screenshot, I can either:
Let’s assume I have n (where n>=10) snowflake tables to read and eventually I would be joining them, each table is having 300+ columns and I need to prefix/suffix those column names in my snapLogic pipeline ONLY with something through which I can distinguish each field name.
Is it possible to do that inside a mapper snap? I’m fine to use the same field name as Input Schema but the only addition would be a prefix/suffix text and that to saving manual efforts on 300+ columns for n different tables I read.
Screenshot below on how I would want each field name to appear with reduced manual efforts (it could be either of prefix or suffix, I’m not looking for a combination at this point of time)
P.S.: If there is any other snap than mapper
that does the job for me, I would appreciate the help and leads.
Thanking in advance.
Best Regards,
DT
Solved! Go to Solution.
05-25-2022 07:26 AM
Remapping all field names can be done using the Object.mapKeys() method. For example:
Hope this helps!
08-30-2023 05:24 AM
Hi @mkadange,
Welcome to SnapLogic and community. Yes, you can simply drag and drop the columns on the target path as you did for input/expression. Please try that out once for a small set and selecting All and dropping it on the target will do the needful.
Also, let's assume, out of 400, you need to select 40 which are not in the order, drag and drop will automatically map it for you.
Please keep us posted with your results.
Regards,
Darsh
05-25-2022 07:26 AM
Remapping all field names can be done using the Object.mapKeys() method. For example:
Hope this helps!
05-25-2022 07:44 AM
Thank you @koryknick for the solution. It worked!
I was also able to play around with that and found a way to suffix as well as use a combination of both suffix and prefix.
Prefix:
$.mapKeys((elem,key) => "sfdc_"+key)
Suffix:
$.mapKeys((elem,key) => key + "_DT")
Combination of prefix and suffix:
$.mapKeys((elem1,key,elem) => "SL_" + key + "_DT")
Thanks again for your help 🙂
05-25-2022 07:54 AM
The format of .mapKeys is very vital as I tried the below formats and it completely changed what I wanted to achieve:
$.mapKeys((key,elem) => key+"_sfdc")
$.mapKeys((key,elem) => "sfdc_"+key)
08-28-2023 10:06 AM
Hello Darsh and Kory,
I am new to Snaplogic, need your help.
I have a similar requirement where in I need to pre-populate both expression and Target path in mapper snap. so I am entering them as 2 rows of input values in the csv generator snap.
When the pipeline is validated like how the left side can be auto populated in the mapping table[by doing select all and dragging and dropping to mapping table], can the right side[target path] also be done something similar?
I need to do this for a large number of columns[400+] and assigning the column names manually on the right side is very tedious and time consuming. So I am trying to find if that step can be automated in anyway.
Any help is greatly appreciated. Thanks!