utafrali commented on code in PR #29646:
URL: https://github.com/apache/flink/pull/29646#discussion_r4397499952
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/join/interval/TimeIntervalJoin.java:
##########
@@ -321,8 +321,10 @@ public void processElement1(RowData leftRow, Context ctx,
Collector<RowData> out
// ordered keys.
}
}
- // Check if we need to cache the current row.
- if (rightOperatorTime < rightQualifiedUpperBound) {
+ // Check if we need to cache the current row. A row that can never
match is only cached to
+ // pad it with nulls once its window has closed.
+ if (rightOperatorTime < rightQualifiedUpperBound
+ && (joinType.isLeftOuter() ||
!joinFunction.currentKeyCannotMatch())) {
Review Comment:
The guard `joinType.isLeftOuter() || !joinFunction.currentKeyCannotMatch()`
evaluates `currentKeyCannotMatch()` on every record on the hot per-record path,
re-running the null-check even for records that are kept. Since the result only
depends on the current join key, consider caching it once per key change, or at
minimum short-circuiting via the cheaper `!nullSafe` check first. Minor perf
concern given the "runtime per-record code paths" sensitivity flagged in the PR
template.
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/join/interval/IntervalJoinFunction.java:
##########
@@ -90,4 +87,12 @@ public TypeInformation<RowData> getProducedType() {
public void setJoinKey(RowData currentKey) {
this.joinKey = (NullAwareGetters) currentKey;
}
+
+ /**
+ * Returns whether no record of the current join key can ever match,
because the key has a null
+ * in a field that is not null-safe. The join key must be set.
+ */
+ public boolean currentKeyCannotMatch() {
Review Comment:
The javadoc states "The join key must be set" but there is no guard
(assertion or null check) to catch misuse. Since `currentKeyCannotMatch()` is
now a public method exposed to callers like `TimeIntervalJoin`, consider adding
`Preconditions.checkState(joinKey != null, "joinKey must be set via
setJoinKey() before calling currentKeyCannotMatch()")` to make the contract
explicit and fail fast if the ordering is ever violated.
##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/join/window/utils/WindowJoinHelper.java:
##########
@@ -98,6 +103,8 @@ public WindowJoinHelper(
this.collector = collector;
this.windowJoinProcessor = getWindowJoinProcessor(joinType);
+ this.leftUnmatchedIsEmitted = joinType.isLeftOuter() || joinType ==
FlinkJoinType.ANTI;
+ this.rightUnmatchedIsEmitted = joinType.isRightOuter();
Review Comment:
The derivation `leftUnmatchedIsEmitted = joinType.isLeftOuter() || joinType
== FlinkJoinType.ANTI` mixes a method call with a direct enum comparison. For
readability and parity with `rightUnmatchedIsEmitted`, consider either
introducing a helper (e.g. `joinType.emitsUnmatchedLeft()`) on `FlinkJoinType`,
or at minimum adding a brief inline comment explaining why SEMI is excluded but
ANTI is included (SEMI drops unmatched left rows while ANTI emits them). Future
readers will otherwise need to re-derive this from the join semantics.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]