Forum Discussion

Rahul's avatar
Rahul
New Contributor III
3 years ago

How to check list of string present Another Column

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

  • 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.

  • Rahul's avatar
    Rahul
    New Contributor III

    There is a slight requirement change. I have to check guam column values in 360 columns and if all values of guam present in 360 then return true else false

    “360”: “A,B,C,D,F”

    Guam": “A,B,C,D”