You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/12/26 01:45:28 UTC
[GitHub] [flink] swuferhong commented on a diff in pull request #21487: [FLINK-30270][table-planner] Fix FlinkJoinToMultiJoinRule incorrectly combines Left/Right outer join to MultiJoin error
swuferhong commented on code in PR #21487:
URL: https://github.com/apache/flink/pull/21487#discussion_r1057024501
##########
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/rules/logical/FlinkJoinToMultiJoinRule.java:
##########
@@ -178,6 +193,60 @@ public void onMatch(RelOptRuleCall call) {
call.transformTo(multiJoin);
}
+ private void buildInputNullGenFieldList(
+ RelNode left, RelNode right, JoinRelType joinType, List<Boolean> isNullGenFieldList) {
+ if (joinType == JoinRelType.INNER) {
+ buildNullGenFieldList(left, isNullGenFieldList);
+ buildNullGenFieldList(right, isNullGenFieldList);
+ } else if (joinType == JoinRelType.LEFT) {
+ // left judge.
+ buildNullGenFieldList(left, isNullGenFieldList);
+
+ for (int i = 0; i < right.getRowType().getFieldCount(); i++) {
+ isNullGenFieldList.add(true);
+ }
+ } else if (joinType == JoinRelType.RIGHT) {
+ for (int i = 0; i < left.getRowType().getFieldCount(); i++) {
+ isNullGenFieldList.add(true);
+ }
+
+ // right judge.
+ buildNullGenFieldList(right, isNullGenFieldList);
+ } else if (joinType == JoinRelType.FULL) {
+ for (int i = 0; i < left.getRowType().getFieldCount(); i++) {
+ isNullGenFieldList.add(true);
+ }
+ for (int i = 0; i < right.getRowType().getFieldCount(); i++) {
+ isNullGenFieldList.add(true);
+ }
+ }
+ }
+
+ private void buildNullGenFieldList(RelNode rel, List<Boolean> isNullGenFieldList) {
+ MultiJoin multiJoin = rel instanceof MultiJoin ? (MultiJoin) rel : null;
+ if (multiJoin == null) {
+ // other operator.
+ for (int i = 0; i < rel.getRowType().getFieldCount(); i++) {
+ isNullGenFieldList.add(false);
+ }
+ } else {
+ List<RelNode> inputs = multiJoin.getInputs();
+ List<JoinRelType> joinTypes = multiJoin.getJoinTypes();
+ for (int i = 0; i < inputs.size() - 1; i++) {
+ if (joinTypes.get(i) == JoinRelType.RIGHT) {
Review Comment:
> can you explain why we should just handle RIGHT here?
When building a `multiJoin`, the right join node is a special one. In joinType list `multiJoin.joinRelType`, the right join nodes will be addad as `[RIGHT, INNER]` in joinType list. however, the inner join nodes and right join nodes will be added as `[INNER, INNER]` and `[INNER, LEFT]` perspectively. Therefore, we just handle right join nodes here to obtain the join type in index `i`.
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org