Created
January 1, 2019 17:10
-
-
Save manishkkatoch/c747a510c956721a27df153769ffde26 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) { | |
def withKey[K](column: Witness.Lt[Symbol])(implicit | |
lhsExists: PropertyExists[L, column.T, K], | |
rhsExists: PropertyExists[R, column.T, K]): DataFrame = | |
doJoin(Seq(column.value.name)) | |
private def doJoin(columns: Seq[String]) = 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