1

I have several dataframes and I want to uniquely identify each row in each dataframe. Hence I want to use personalized Ids . I am using the monotonically_increasing_id() built-in function in spark as follows:

import org.apache.spark.sql.functions._
val dfWithId = trzuCom.withColumn("UniqueID", monotonically_increasing_id)

The problem is when I try to personalize it as follows :

val dfWithId = trzuCom.withColumn("UniqueID", "TB1_" + monotonically_increasing_id)

I get errors. Actually I want to have TB1_ID for dataframe 1, TB2_ID and so one . Any I dea how to do this please. Best Regards

scalacode
  • 1,096
  • 1
  • 16
  • 38

0 Answers0