Created
May 28, 2020 16:55
-
-
Save leifwickland/9d2e3f7b51bc4562f40930a6f6a4a975 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
import com.rubiconproject.dt.silvergate.sparktest.SharedSparkSession | |
import com.rubiconproject.science.util.SparkImplicitsWithoutSqlContext._ | |
import org.specs2.mutable.Specification | |
import scala.util.Random | |
import ExampleRollupTest._ | |
class ExampleRollupTest extends Specification with SharedSparkSession { | |
"a" should { | |
"b" in { | |
import sparkSession.implicits._ | |
val df = rs.toDF | |
df.show(100, 1000) | |
df.rollup("c", "b", "a").sum("m1", "m2").show(100, 1000) | |
ok | |
} | |
} | |
} | |
object ExampleRollupTest { | |
case class R(a: String, b: String, c: String, m1: Int, m2: Int) | |
val rs: Seq[R] = for { | |
a <- (1 to 3) | |
b <- (1 to 3) | |
c <- 1 to 3 | |
} yield R(s"a$a", s"b$b", s"c$c", Random.nextInt(), Random.nextInt()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment