val df1 = Seq(("[1,10,20]", "bat","43243"),("[20,4,10]","mouse","4324432"),("[30,20,3]", "horse","4324234")).toDF("id", "word","userid")
val df2 = Seq((1, "raj", "name"),(2, "kiran","name"),(3,"karnataka","state"),(4, "Andrapradesh","state")).toDF("id", "name", "code")
Explanation:
I have two dataframes df1 & df2. df1 is having id column which is having a list of ids.
I need to check any one of the ids is present in the df2 dataframe.
Conditions
if id is present in the df2 id column and if the code is state then get the name of the particular id from the df2 and create a new data frame with name column
Expected Output
id | word | userid | name
-------------------------+-----------------------
[30,20,3] | "horse" | "4324234" | "karnataka"
[20,4,10] | "mouse" | "4324432" | "Andrapradesh"