Create a DataFrame:
var in=spark.read.json("sample.json");
Register the UDF (User Defined Function)
import java.util.UUID val generateUUID = udf(() => UUID.randomUUID().toString)
Generate a new Column
val withUUID= in.withColumn("uuid",generateUUID());