Skip to content

Instantly share code, notes, and snippets.

@dmateusp
Created June 4, 2019 07:03
Show Gist options
  • Save dmateusp/4cef1b6d28208e04a16235178189ec8e to your computer and use it in GitHub Desktop.
Save dmateusp/4cef1b6d28208e04a16235178189ec8e to your computer and use it in GitHub Desktop.
DataFrame.transform - Spark Function Composition - final functions examples
// chain transform calls
dfTransactions
.transform(extractPayerBeneficiary("details"))
.transform(sumAmounts(date_trunc("day", col("ts")), col("details_beneficiary")))
// andThen
dfTransactions
.transform(extractPayerBeneficiary("details") andThen sumAmounts(date_trunc("day", col("ts")), col("details_beneficiary")))
// compose
dfTransactions
.transform(sumAmounts(date_trunc("day", col("ts")), col("details_beneficiary")) compose extractPayerBeneficiary("details"))
// Function.chain
dfTransactions
.transform(Function.chain(List(extractPayerBeneficiary("details"), sumAmounts(date_trunc("day", col("ts")), col("details_beneficiary")))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment