Skip to content

Instantly share code, notes, and snippets.

@fwbrasil
Last active November 7, 2017 20:50
Show Gist options
  • Save fwbrasil/c8b0f39b2ea4cf911309229a2b83bf24 to your computer and use it in GitHub Desktop.
Save fwbrasil/c8b0f39b2ea4cf911309229a2b83bf24 to your computer and use it in GitHub Desktop.
case class Person(name: String, age: Int)
case class Couple(p1: String, p2: String)
def sameAgeCouples(
people: Dataset[Person],
couples: Dataset[Couple]
): Dataset[Couple] =
run {
for {
p1 <- liftQuery(people)
p2 <- liftQuery(people)
c <- liftQuery(couples)
if (c.p1 == p1.name &&
c.p2 == p2.name &&
p1.age == p2.age)
} yield {
c
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment