The Hadoop in Real World team does some stacking:
stack function in Spark takes a number of rows as an argument followed by expressions.
stack(n, expr1, expr2.. exprn)
stack function will generate n rows by evaluating the expressions.
Think of it as the Spark alternative to UNPIVOT
.