wuchong commented on a change in pull request #14404:
URL: https://github.com/apache/flink/pull/14404#discussion_r546488388



##########
File path: 
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/rules/physical/stream/StreamExecJoinRuleBase.scala
##########
@@ -70,28 +70,30 @@ abstract class StreamExecJoinRuleBase(description: String)
           .replace(distribution)
     }
 
-    val newRight = right match {
-      case snapshot: FlinkLogicalSnapshot =>
-        snapshot.getInput
-      case rel: FlinkLogicalRel => rel
+    def convertInput(input: RelNode, columns: util.Collection[_ <: Number]): 
RelNode = {
+      val requiredTraitSet = toHashTraitByColumns(columns, input.getTraitSet)
+      RelOptRule.convert(input, requiredTraitSet)
     }
 
     val joinInfo = join.analyzeCondition
-    val (leftRequiredTrait, rightRequiredTrait) = (
-        toHashTraitByColumns(joinInfo.leftKeys, left.getTraitSet),
-        toHashTraitByColumns(joinInfo.rightKeys, newRight.getTraitSet))
-
-    val convertedLeft: RelNode = RelOptRule.convert(left, leftRequiredTrait)
-    val convertedRight: RelNode = RelOptRule.convert(newRight, 
rightRequiredTrait)
     val providedTraitSet: RelTraitSet = 
join.getTraitSet.replace(FlinkConventions.STREAM_PHYSICAL)
 
-    val newJoin = transform(join, convertedLeft, convertedRight, 
providedTraitSet)
+    val leftConversion = leftInput => {
+      convertInput(leftInput, joinInfo.leftKeys)
+    }
+    val rightConversion = rightInput => {
+      convertInput(rightInput, joinInfo.rightKeys)
+    }
+
+    val newJoin = transform(join, left, leftConversion, right, 
rightConversion, providedTraitSet)
     call.transformTo(newJoin)
   }
 
   protected def transform(
       join: FlinkLogicalJoin,
-      convertedLeft: RelNode,
-      convertedRight: RelNode,
+      leftInput: FlinkRelNode,

Review comment:
       I think we don't need the `leftInput` parameter, it can be derived from 
the join node `join.getLeft`.




----------------------------------------------------------------
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]


Reply via email to