Skip to content
Advertisement

How to merge rows using SQL only?

I can neither use pyspark or scala. I can only write SQL code. I have a table with 2 columns item id, name.

I want to generate results with the names of an item_id concatenated.

How do I create such a table with Spark sql?

Advertisement

Answer

The beauty of Spark SQL is that once you have a solution in any of the supported languages (Scala, Java, Python, R or SQL) you can somewhat figure out other variants.

The following SQL statement seems doing what you ask for:


In spark-shell it gives the following result:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement