I need to generate a new column in my DataFrame with random timestamps that would have a step of seconds. The DataFrame contains 10.000 rows.
The starting timestamp should be 1516364153.
I tried to solve the problem as follows:
df.withColumn("timestamp",lit(1516364153 + scala.util.Random.nextInt(2000)))
However, all timestamps are equal to some specific value, for example, 1516364282 instead of many different values. There might be some duplicates, but why all values are the same? It looks like only one random number has been generated and then it's propagated over the whole column.
How can I solve this problem?