Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Save Case Class as TSV On Spark
implicit class ProductRDD[T <: Product](rdd: RDD[T]) {
/* Saves a RDD of Tuples into a TSV.
* Ex: Employee(emp_id = 123, Name(first="Bob",last="Smith")) => "123\tBob\tSmith"
def saveAsTsv(path: String) { => p.productIterator.flatMap {
case a: Product => a.productIterator //flattens nested case classes
case b => Seq(b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.