join
Joins two DataFrame
object by join columns.
join(otherDf, type = JoinType.Inner) [ { joinColumns } ]
joinColumns: JoinDsl.(LeftDataFrame) -> Columns
interface JoinDsl: LeftDataFrame {
val right: RightDataFrame
fun DataColumn.match(rightColumn: DataColumn)
}
joinColumns
is a column selector that defines column mapping for join:
df.join(other) { name match right.fullName }
val name by columnGroup()
val fullName by columnGroup()
df.join(other) { name match fullName }
df.join(other) { "name" match "fullName" }
If mapped columns have the same name, just select join columns from the left DataFrame
:
df.join(other) { name and city }
val name by columnGroup()
val city by column<String>()
df.join(other) { name and city }
df.join(other, "name", "city")
If joinColumns
is not specified, columns with the same name from both DataFrame
objects will be used as join columns:
df.join(other)
Join types
Supported join types:
Inner
(default) — only matched rows from left and right DataFrame
objects
Filter
— only matched rows from left DataFrame
Left
— all rows from left DataFrame
, mismatches from right DataFrame
filled with null
Right
— all rows from right DataFrame
, mismatches from left DataFrame
filled with null
Full
— all rows from left and right DataFrame
objects, any mismatches filled with null
Exclude
— only mismatched rows from left DataFrame
For every join type there is a shortcut operation:
df.innerJoin(other) { name and city }
df.leftJoin(other) { name and city }
df.rightJoin(other) { name and city }
df.fullJoin(other) { name and city }
df.excludeJoin(other) { name and city }
val name by columnGroup()
val city by column<String>()
df.innerJoin(other) { name and city }
df.leftJoin(other) { name and city }
df.rightJoin(other) { name and city }
df.fullJoin(other) { name and city }
df.excludeJoin(other) { name and city }
df.innerJoin(other, "name", "city")
df.leftJoin(other, "name", "city")
df.rightJoin(other, "name", "city")
df.fullJoin(other, "name", "city")
df.excludeJoin(other, "name", "city")
Last modified: 27 September 2024