cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to check list of string present Another Column

Rahul
New Contributor III

Hi,

I have one requirement in this there is one API return list of values comma separated and Another column coming from Snowflake and I need to compare and generate a flag
Note : order of strings are not fixed
Example Column1: [โ€˜STRING1โ€™,โ€˜STRING2โ€™,โ€˜STRING3โ€™,โ€˜STRING4โ€™]

Column2: [โ€˜STRING1โ€™,โ€˜STRING2โ€™,โ€˜STRING3โ€™,โ€˜STRING4โ€™]

5 REPLIES 5

AleksandarAngel
Contributor III

Hello @Rahul,

You can compare the two list by first merging them using the Join Snap. Then, using the following expression in a Mapper Snap to compare the lists:

$api_list.length == $snowflake_list.length ? ($api_list.filter(x => $snowflake_list.indexOf(x) != -1).length == $api_list.length) : false

Here is a sample pipeline:
โ€“sl-comm-compare-lists_2023_07_08.slp (6.6 KB)

Let me know if this is of any help. ๐Ÿ™‚

Regards,
Aleksandar.

@AleksandarAngel  - Can you please share the sample pipeline as I am getting Page not found error

Hello @Imran ,

Please find the sample pipeline attached.

 

Thank you @AleksandarAngel 

Also, Is there a way to easily show what key values do not match between two JSON objects?