jfpelletier
2 years agoContributor
Converting Snowflake Lookup results into an array
Hello all, I'm using the Snowflake Lookup snap to query a table that contains the details of projects already processed, and get the values of the "project ID" column. The values are unique project ...
- 2 years ago
Hi jfpelletier ,
I did the below to get the UIDs in an array, maybe you fine-tune it a bit more to reduce the snaps:
Input:
[ {"UID":"UID1"}, {"UID":"UID2"}, {"UID":"UID3"}, {"UID":"UID4"} ]
I used a mapper snap after this and since we want to get all documents in a single array, I added the below expression to extend the UID doc with a common value that I can use later in group by fields snap to group all the records.
$.extend({"group":"1"})
The output of this mapper looks like this:
Later I added a group by fields snap and grouped the input based on the group tag:
The output will be an array of all documents where the group has same value, in our case it'll be the same for all records of UIDs.
Added another mapper with the below expression:
jsonPath($, "group[*].UID")
The final o/p looks like this:
Hope this helps.
Cheers,
Abhishek