Created
January 1, 2019 17:11
-
-
Save manishkkatoch/2e6468791b1172d14be823dfcf3cb84c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JoinDataSet[L, R](lhs: Dataset[L], rhs: Dataset[R], joinType: String) { | |
object on extends SingletonProductArgs { | |
def applyProduct[V <: HList, K](columns: V)(implicit | |
i0: ToTraversable.Aux[V, List, Symbol], | |
lhsExists: PropertiesExists[L, V, K], | |
rhsExists: PropertiesExists[R, V, K]): DataFrame = | |
doJoin(columns.toList[Symbol].map(_.name)) | |
} | |
private def doJoin(columns: Seq[String]) = lhs.join(rhs, columns, joinType) | |
private def doJoin(columns: Column) = lhs.join(rhs, columns, joinType) | |
} | |
object JoinDataSet { | |
def apply[L, R](lhs: Dataset[L], rhs: Dataset[R], joinType: String) = new JoinDataSet(lhs, rhs, joinType) | |
def leftJoin[L, R](lhs: Dataset[L], rhs: Dataset[R]) = JoinDataSet(lhs, rhs, "leftOuter") | |
def rightJoin[L, R](lhs: Dataset[L], rhs: Dataset[R]) = JoinDataSet(lhs, rhs, "rightOuter") | |
def fullOuterJoin[L, R](lhs: Dataset[L], rhs: Dataset[R]) = JoinDataSet(lhs, rhs, "fullOuter") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment