I have a DataFrame, that i want to join with another Dataframe, and then group by original rows, but the original rows do not have a unique id. How can i add a unique id or otherwise accomplish that goal.
You can use monotonically_increasing_id
import org.apache.spark.sql.functions._
val unique_df = original_df.withColumn("UniqueID", monotonically_increasing_id)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With