JingsongLi commented on a change in pull request #8629: 
[FLINK-12088][table-runtime-blink] Introduce unbounded streaming 
inner/left/right/full join operator
URL: https://github.com/apache/flink/pull/8629#discussion_r291042767
 
 

 ##########
 File path: 
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/plan/nodes/physical/stream/StreamExecJoin.scala
 ##########
 @@ -123,7 +139,132 @@ class StreamExecJoin(
 
   override protected def translateToPlanInternal(
       tableEnv: StreamTableEnvironment): StreamTransformation[BaseRow] = {
-    throw new TableException("Implements this")
+
+    val tableConfig = tableEnv.getConfig
+    val returnType = FlinkTypeFactory.toInternalRowType(getRowType).toTypeInfo
+
+    val leftTransform = getInputNodes.get(0).translateToPlan(tableEnv)
+      .asInstanceOf[StreamTransformation[BaseRow]]
+    val rightTransform = getInputNodes.get(1).translateToPlan(tableEnv)
+      .asInstanceOf[StreamTransformation[BaseRow]]
+
+    val leftType = leftTransform.getOutputType.asInstanceOf[BaseRowTypeInfo]
+    val rightType = rightTransform.getOutputType.asInstanceOf[BaseRowTypeInfo]
+
+    val (leftJoinKey, rightJoinKey) =
+      JoinUtil.checkAndGetJoinKeys(keyPairs, getLeft, getRight, allowEmptyKey 
= true)
+
+    val leftSelect = KeySelectorUtil.getBaseRowSelector(leftJoinKey, leftType)
+    val rightSelect = KeySelectorUtil.getBaseRowSelector(rightJoinKey, 
rightType)
+
+    val leftInputSpec = analyzeJoinInput(left)
+    val rightInputSpec = analyzeJoinInput(right)
+
+    val generatedCondition = generateConditionFunction(tableConfig, leftType, 
rightType)
+
+    if (joinType == JoinRelType.ANTI || joinType == JoinRelType.SEMI) {
+      throw new TableException("SEMI/ANTI Join is not supported yet.")
+    }
+
+    val leftIsOuter = joinType == JoinRelType.LEFT || joinType == 
JoinRelType.FULL
+    val rightIsOuter = joinType == JoinRelType.RIGHT || joinType == 
JoinRelType.FULL
+    val minRetentionTime = tableConfig.getMinIdleStateRetentionTime
+
+    val operator = new StreamingJoinOperator(
+      leftType,
+      rightType,
+      generatedCondition,
+      leftInputSpec,
+      rightInputSpec,
+      leftIsOuter,
+      rightIsOuter,
+      filterNulls,
+      minRetentionTime)
+
+    val ret = new TwoInputTransformation[BaseRow, BaseRow, BaseRow](
+      leftTransform,
+      rightTransform,
+      "Join",
+      operator,
+      returnType,
+      leftTransform.getParallelism)
+
+    if (leftJoinKey.isEmpty) {
+      ret.setParallelism(1)
+      ret.setMaxParallelism(1)
+    }
+
+    // set KeyType and Selector for state
+    ret.setStateKeySelectors(leftSelect, rightSelect)
+    
ret.setStateKeyType(leftSelect.asInstanceOf[ResultTypeQueryable[_]].getProducedType)
+    ret
+  }
+
+  private[flink] def generateConditionFunction(
 
 Review comment:
   This method is almost same to `BatchExecJoinBase.generateCondition`, can you 
merge them?

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to