I am trying to convert the below SQL server query into a Spark SQL query but I am not able to do this as there is not any specific function in pyspark sql.
STRING_AGG(table.reference, ' - ') within GROUP (ORDER BY table.keyid) AS description,
STRING_AGG(case when eventtype = 'paramlist' then table.reference end, ' - ') within GROUP (ORDER BY table.keyid) AS test,
STRING_AGG(case when eventtype = 'sample' then table.reference end, ' - ') within GROUP (ORDER BY table.keyid) AS sample,
STRING_AGG(case when eventtype = 'Lot' then table.reference end, ' - ') within GROUP (ORDER BY table.keyid) AS lot