Skip to content

Instantly share code, notes, and snippets.

@aialenti
Last active June 21, 2020 11:28
Show Gist options
  • Save aialenti/27a0853a69f56057c6d6ed94df9be2a7 to your computer and use it in GitHub Desktop.
Save aialenti/27a0853a69f56057c6d6ed94df9be2a7 to your computer and use it in GitHub Desktop.
// Scala random numbers generator
val r = scala.util.Random
// Create a "population" dataset with the numbers between 0 and 1000
val population:List[List[Int]] = for {
i <- (0 to 1000).toList
d <- 1 to 1
} yield List(d,i)
val df = population.map(x =>(x(0), x(1))).toDF(Seq("dummy_key","suffix"):_*)
// Append the new column
dimension_table2 = dimension_table2.crossJoin(df).
withColumn("id_suffix", concat(col("id"),lit("-"),col("suffix")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment