Forum Discussion
@nsingam : Thank you for your example! That’s a good step-by-step example of how someone can change the format of the data for use elsewhere, and even accommodates the other metadata items 2 and 3.
I do happen to really like @koryknick 's example, however, since it leaves the rest of the object intact, and is a very elegant example of the Object.mapKeys() function! His manages to get to the target system format in 2 snaps. It’s pretty neat that we have both a mapKeys and mapValues in our toolbox to use in situations like this.
Here’s the sample pipeline that does the transformation.
GravityFormsReassemble_2022_07_08.slp (8.8 KB)
Thank you both!
A document should not be modified once it has been written to the output view. Making a copy of the document avoids issues. Change the loop to create a new wrapper Map
for item in sourceTables: wrapper = java.util.HashMap(in_doc) wrapper['query'] = "update iods_staging.{} set record_inserted = true;".format(item) self.output.write(wrapper)
- aditya_sharma8 years agoNew Contributor III
Hi Akidave,
Thanks you so much for your solution. However, I would really appreciate if you could explain me more why we should not modify the document once it has been written to the output view.
Thanks again.
Aditya
- aditya_sharma8 years agoNew Contributor III
Hi Dmiller,
Please find below output from script snap and mapper output. Mapper output has two update statements same which is incorrect, it has to be same like script.
Script Snap:
“query”: “update iods_staging.stg_sf_account_dim_institution set record_inserted = true;”
“query”: “update iods_staging.stg_sf_accountdistict_dim_institution set record_inserted = true;”
“query”: “update iods_staging.stg_sf_recordtype_dim_institution set record_inserted = true;”Mapper Output:
“query”
“update iods_staging.stg_sf_account_dim_institution set record_inserted = true;”
“update iods_staging.stg_sf_recordtype_dim_institution set record_inserted = true;”
“update iods_staging.stg_sf_recordtype_dim_institution set record_inserted = true;”Thanks
Aditya
Related Content
- 3 years ago
- 4 years ago
- 10 months ago