โ04-21-2021 09:52 PM
We need to merge multiple documents to single array and looking for help. Since it is ultra task, we are running out of optionsโฆ
Input data:
[
{โRecordโ: โ1โ},
{โRecordโ: โ2โ},
{โRecordโ: โ5โ},
{โRecordโ: โ4โ},
{โRecordโ: โ6โ}
]
Expected Output:
[ โresponseโ: [{โRecordโ: โ1โ}, {โRecordโ: โ2โ}, {โRecordโ: โ5โ}, {โRecordโ: โ4โ}, {โRecordโ: โ6โ}]
]
โ04-22-2021 09:26 AM
I donโt have a DB2 instance to test with at the moment, but it appears you could do the same thing with different syntax:
โ04-22-2021 09:30 AM
It should be noted that Iโm recommending that you push the creation of the array back to the source database because you are trying to prevent calling a child pipeline, which is the recommended pattern for aggregating data in an Ultra pipeline. This is required because Ultra is a streaming service of one record in, one record out. So any type of function that aggregates data (including Sort, Group By *, etc) will be stuck waiting on end of upstream input which will never come because of the nature of the data flow in Ultra. This is also why your Script snap isnโt working the way you were expecting - itโs waiting on the end of input, which never comes in an Ultra pipeline.
โ04-22-2021 04:31 PM
Hi again @thilkip,
This task of yours was very intriguing, so I dedicated quite sometime experimenting and I found a solution that works in development mode, with snaps supported by Ultra Task. Here is the pipeline:
Documents_to_Array_Format.slp (7.3 KB)
Here is the final result:
I am pretty curious about this one, can you please send feedback on the pipelineโs behaviour?
In addition I am sending you a Python script, that is also tested and works. I know that you allready tried with a script but I am offering some options. Thanks,
Doc_to_Array.txt (1.6 KB)
Best Regards,
Bojan
โ04-23-2021 06:11 AM
Thank you for your time and help. We did validate the script in ultra task and saw the same behavior like earlier.
We will test the other approach using Formatter snap and let you know.
Thank you again
โ02-04-2022 06:08 AM
@thilkip Have you been able to achieve this scenario using the Script in the Ultra sscenario. We ran in to the same problem