dawidwys commented on code in PR #24253:
URL: https://github.com/apache/flink/pull/24253#discussion_r1481739305


##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/plan/rules/logical/LogicalCorrelateToJoinFromTemporalTableRule.scala:
##########
@@ -323,15 +306,47 @@ abstract class 
LogicalCorrelateToJoinFromGeneralTemporalTableRule(
     }
 
     val builder = call.builder()
-    val condition = builder.and(joinCondition, temporalCondition)
-
-    builder.push(leftInput)
-    builder.push(snapshot)
-    builder.join(correlate.getJoinType, condition)
-    val temporalJoin = builder.build()
+    val condition = builder.and(actualJoin.getCondition, temporalCondition)
+
+    val joinWithTemporalCondition = actualJoin.copy(
+      actualJoin.getTraitSet,
+      condition,
+      actualJoin.getLeft,
+      actualJoin.getRight,
+      actualJoin.getJoinType,
+      actualJoin.isSemiJoinDone)
+
+    val temporalJoin = if (actualJoin != rewriteJoin) {
+      rewriteJoin.replaceInput(0, joinWithTemporalCondition)

Review Comment:
   I admit I had to check this again, but we add the projection if we pushed 
anything down. If we don't we don't have the extra projection. We have cases 
for that (basically all tests before this PR).



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to