vanzin commented on a change in pull request #26108: [SPARK-26154][SS]
Streaming left/right outer join should not return outer nulls for already
matched rows
URL: https://github.com/apache/spark/pull/26108#discussion_r338828093
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/SymmetricHashJoinStateManager.scala
##########
@@ -82,40 +88,65 @@ class SymmetricHashJoinStateManager(
}
/** Append a new value to the key */
- def append(key: UnsafeRow, value: UnsafeRow): Unit = {
+ def append(key: UnsafeRow, value: UnsafeRow, matched: Boolean): Unit = {
val numExistingValues = keyToNumValues.get(key)
- keyWithIndexToValue.put(key, numExistingValues, value)
+ keyWithIndexToValue.put(key, numExistingValues, value, matched)
keyToNumValues.put(key, numExistingValues + 1)
}
+ /**
+ * Get all the matched values for given join condition, with marking matched.
+ * This method is designed to mark joined rows properly without exposing
internal index of row.
+ */
+ def getJoinedRows(
+ key: UnsafeRow,
+ generateJoinedRow: InternalRow => JoinedRow,
+ predicate: JoinedRow => Boolean): Iterator[JoinedRow] = {
+ val numValues = keyToNumValues.get(key)
+ keyWithIndexToValue.getAll(key, numValues).map { keyIdxToValue =>
+ val joinedRow = generateJoinedRow(keyIdxToValue.value)
+ if (predicate(joinedRow)) {
+ if (!keyIdxToValue.matched) {
+ // only update when matched flag is false
Review comment:
comment just repeats the code.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]