Github user fhueske commented on a diff in the pull request: https://github.com/apache/flink/pull/5140#discussion_r159012517 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/join/TimeBoundedStreamJoin.scala --- @@ -241,17 +288,66 @@ abstract class TimeBoundedStreamInnerJoin( if (leftTime >= leftQualifiedLowerBound && leftTime <= leftQualifiedUpperBound) { val leftRows = leftEntry.getValue var i = 0 + var markEmitted = false while (i < leftRows.size) { - joinFunction.join(leftRows.get(i), rightRow, cRowWrapper) + joinCollector.resetThisTurn() + val tuple = leftRows.get(i) + joinFunction.join(tuple.f0, rightRow, joinCollector) + if (joinType == JoinType.LEFT_OUTER || joinType == JoinType.FULL_OUTER) { + if (!tuple.f1 && joinCollector.everEmittedThisTurn) { + // Mark the left 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. + leftEntry.setValue(leftRows) + } } if (leftTime <= leftExpirationTime) { + if (joinType == JoinType.RIGHT_OUTER || joinType == JoinType.FULL_OUTER) { --- End diff -- `JoinType.RIGHT_OUTER` should be `JoinType.LEFT_OUTER`
---