Skip to content

Instantly share code, notes, and snippets.

@leifwickland
Created May 28, 2020 16:55
Show Gist options
  • Save leifwickland/9d2e3f7b51bc4562f40930a6f6a4a975 to your computer and use it in GitHub Desktop.
Save leifwickland/9d2e3f7b51bc4562f40930a6f6a4a975 to your computer and use it in GitHub Desktop.
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