HIVE
- join
- left out join
- right out join
- full out join
- left semi join
- cross join
SparkRDD:
- join
- leftOutJoin
- rightOutJoin
- fullOutJoin
使用示范:
val b: RDD[(Int, String)] = a.keyBy(x=>x.length)
val c=b
b.fullOuterJoin(b)
Spark DF、DS:
- inner
- outer, full, fullouter
- leftouter, left
- rightouter, right
- leftsemi
- leftanti
- cross
使用示范:
import spark.implicits._
val df2 = b.toDF("x","y")
val df3=df2
df2.join(df3,df2("x")===df3("x"),"leftouter").show
源码:
object JoinType {
def apply(typ: String): JoinType = typ.toLowerCase(Locale.ROOT).replace("_", "") match {
case "inner" => Inner
case "outer" | "full" | "fullouter" => FullOuter
case "leftouter" | "left" => LeftOuter
case "rightouter" | "right" => RightOuter
case "leftsemi" => LeftSemi
case "leftanti" => LeftAnti
case "cross" => Cross
case _ =>
val supported = Seq(
"inner",
"outer", "full", "fullouter",
"leftouter", "left",
"rightouter", "right",
"leftsemi",
"leftanti",
"cross")
throw new IllegalArgumentException(s"Unsupported join type '$typ'. " +
"Supported join types include: " + supported.mkString("'", "', '", "'") + ".")
}
}