I have the query bellow:
finvResultOutput1
.withColumn("offersAtSite",when(col("activeIOsAtSite")==="Y",
finvResultOutput1.select(col("OfferSpecification_displayLabel"),col("Site_siteId").alias("siteid"))
.where(col("Site_siteId")===col("siteid"))
.drop("siteid")
.collect()
))
I want to add a new column to my data frame called offersAtSite, this column should be added when another column called activeIOsAtSite equals "Y".
The value of this new column should be a list without duplicates of the elements of column OfferSpecification_displayLabel where the Site_siteId equals the current Site_siteId of the row we are iterating over.
Could anyone give me a better approach to do that, because the query that I made is taking too much time and I don't know if it is working
Bellow is an example of what I want to achieve:
