Last active
June 21, 2020 11:28
-
-
Save aialenti/27a0853a69f56057c6d6ed94df9be2a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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