wuchong commented on a change in pull request #10144: [FLINK-14613][table-planner-blink] Fix temporal table join when containing multiple keyfields with UDF URL: https://github.com/apache/flink/pull/10144#discussion_r346853266
########## File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/nodes/common/CommonLookupJoin.scala ########## @@ -419,19 +419,17 @@ abstract class CommonLookupJoin( joinKeyPairs: Array[IntPair], joinInfo: JoinInfo, allLookupKeys: Map[Int, LookupKey]): Option[RexNode] = { - val remainingPairs = joinKeyPairs.filter(p => !checkedLookupFields.contains(p.target)) + val joinPairs = joinInfo.pairs().asScala.toArray + val remainingPairs = joinPairs.filter(p => !checkedLookupFields.contains(p.target)) Review comment: This is still not right. If we change the new added test query to the following: ```sql val sql = "SELECT T.id, T.content, D.age FROM T JOIN userTable " + "for system_time as of T.proctime AS D ON T.content = concat(D.name, '!') AND D.age = 11" ``` Just remove the `D.name` from SELECT, the result will be wrong. `checkedLookupFields` is the field index of the dim table, we should reflect to the index of calc. The following diagram explains the internals. ```java * Join (l.name = r.name) * / \ * RelNode Calc (concat(name, "!") as name) * | * DimTable (lookup: age=11) * (age, id, name) * * * joinPairs= "0=0" (equal condition of Join) * joinKeyPairs = empty (left input field index to dim table field index) * checkedLookupFields = 0 (lookup index of "age" field in table) ``` ---------------------------------------------------------------- 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