Skip to content

Commit 133495d

Browse files
chenghao-intelmarmbrus
authored andcommitted
[SQL]Add base row updating methods for JoinedRow
This will be helpful in join operators. Author: Cheng Hao <[email protected]> Closes #1187 from chenghao-intel/joinedRow and squashes the following commits: 87c19e3 [Cheng Hao] Add base row set methods for JoinedRow
1 parent 8ca4176 commit 133495d

File tree

1 file changed

+17
-0
lines changed
  • sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions

1 file changed

+17
-0
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Projection.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ class JoinedRow extends Row {
8181
this
8282
}
8383

84+
/** Updates this JoinedRow by updating its left base row. Returns itself. */
85+
def withLeft(newLeft: Row): Row = {
86+
row1 = newLeft
87+
this
88+
}
89+
90+
/** Updates this JoinedRow by updating its right base row. Returns itself. */
91+
def withRight(newRight: Row): Row = {
92+
row2 = newRight
93+
this
94+
}
95+
8496
def iterator = row1.iterator ++ row2.iterator
8597

8698
def length = row1.length + row2.length
@@ -124,4 +136,9 @@ class JoinedRow extends Row {
124136
}
125137
new GenericRow(copiedValues)
126138
}
139+
140+
override def toString() = {
141+
val row = (if (row1 != null) row1 else Seq[Any]()) ++ (if (row2 != null) row2 else Seq[Any]())
142+
s"[${row.mkString(",")}]"
143+
}
127144
}

0 commit comments

Comments
 (0)