Github user xccui commented on a diff in the pull request: https://github.com/apache/flink/pull/5140#discussion_r159069304 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/join/TimeBoundedStreamJoin.scala --- @@ -182,16 +196,64 @@ abstract class TimeBoundedStreamInnerJoin( if (rightTime >= rightQualifiedLowerBound && rightTime <= rightQualifiedUpperBound) { val rightRows = rightEntry.getValue var i = 0 + var markEmitted = false while (i < rightRows.size) { - joinFunction.join(leftRow, rightRows.get(i), cRowWrapper) + joinCollector.resetThisTurn() + val tuple = rightRows.get(i) + joinFunction.join(leftRow, tuple.f0, joinCollector) + if (joinType == JoinType.RIGHT_OUTER || joinType == JoinType.FULL_OUTER) { + if (!tuple.f1 && joinCollector.everEmittedThisTurn) { + // Mark the right row as being successfully joined and emitted. + tuple.f1 = true + markEmitted = true + } + } i += 1 } + if (markEmitted) { + // Write back the edited entry (mark emitted) for the right cache. + rightEntry.setValue(rightRows) + } } if (rightTime <= rightExpirationTime) { + if (joinType == JoinType.LEFT_OUTER || joinType == JoinType.FULL_OUTER) { --- End diff -- Yes, I should have added a harness test for that.
---