You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/12/03 05:23:14 UTC

[GitHub] [doris] Kikyou1997 opened a new pull request, #14784: [feature](nereids) Support `using join` syntax

Kikyou1997 opened a new pull request, #14784:
URL: https://github.com/apache/doris/pull/14784

   # Proposed changes
   
   Issue Number: close #xxx
   
   ## Problem summary
   
   Describe your changes.
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: 
       - [ ] Yes
       - [ ] No
       - [ ] I don't know
   2. Has unit tests been added:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   3. Has document been added or modified:
       - [ ] Yes
       - [ ] No
       - [ ] No Need
   4. Does it need to update dependencies:
       - [ ] Yes
       - [ ] No
   5. Are there any changes that cannot be rolled back:
       - [ ] Yes (If Yes, please explain WHY)
       - [ ] No
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
   
   


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] morrySnow merged pull request #14784: [feature](nereids) Support `using join` syntax

Posted by GitBox <gi...@apache.org>.
morrySnow merged PR #14784:
URL: https://github.com/apache/doris/pull/14784


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] morrySnow commented on a diff in pull request #14784: [feature](nereids) Support `using join` syntax

Posted by GitBox <gi...@apache.org>.
morrySnow commented on code in PR #14784:
URL: https://github.com/apache/doris/pull/14784#discussion_r1040596125


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSlotReference.java:
##########
@@ -111,19 +114,41 @@ public List<Rule> buildRules() {
                     return new LogicalFilter<>(boundPredicates, filter.child());
                 })
             ),
-            RuleType.BINDING_JOIN_SLOT.build(
-                logicalJoin().when(Plan::canBind).thenApply(ctx -> {
-                    LogicalJoin<GroupPlan, GroupPlan> join = ctx.root;
-                    List<Expression> cond = join.getOtherJoinConjuncts().stream()
-                            .map(expr -> bind(expr, join.children(), join, ctx.cascadesContext))
-                            .collect(Collectors.toList());
-                    List<Expression> hashJoinConjuncts = join.getHashJoinConjuncts().stream()
-                            .map(expr -> bind(expr, join.children(), join, ctx.cascadesContext))
-                            .collect(Collectors.toList());
-                    return new LogicalJoin<>(join.getJoinType(),
-                            hashJoinConjuncts, cond, join.left(), join.right());
-                })
-            ),
+                RuleType.BINDING_JOIN_SLOT.build(
+                        logicalJoin().when(Plan::canBind)
+                                .whenNot(j -> j.getJoinType().equals(JoinType.USING_JOIN)).thenApply(ctx -> {
+                                    LogicalJoin<GroupPlan, GroupPlan> join = ctx.root;
+                                    List<Expression> cond = join.getOtherJoinConjuncts().stream()
+                                            .map(expr -> bind(expr, join.children(), join, ctx.cascadesContext))
+                                            .collect(Collectors.toList());
+                                    List<Expression> hashJoinConjuncts = join.getHashJoinConjuncts().stream()
+                                            .map(expr -> bind(expr, join.children(), join, ctx.cascadesContext))
+                                            .collect(Collectors.toList());
+                                    return new LogicalJoin<>(join.getJoinType(),
+                                            hashJoinConjuncts, cond, join.left(), join.right());
+                                })
+                ),
+                RuleType.BINDING_USING_JOIN_SLOT.build(
+                        logicalJoin().when(j -> j.getJoinType().equals(JoinType.USING_JOIN)).thenApply(ctx -> {
+                            LogicalJoin<GroupPlan, GroupPlan> join = ctx.root;
+                            List<Expression> unboundSlots = join.getHashJoinConjuncts();
+                            List<Expression> leftSlots = unboundSlots.stream()
+                                    .map(expr -> bind(expr, Collections.singletonList(join.left()),
+                                            join, ctx.cascadesContext))
+                                    .collect(Collectors.toList());
+                            List<Expression> rightSlots = unboundSlots.stream()
+                                    .map(expr -> bind(expr, Collections.singletonList(join.right()),
+                                            join, ctx.cascadesContext))
+                                    .collect(Collectors.toList());
+                            int size = leftSlots.size();
+                            List<Expression> hashEqExpr = new ArrayList<>();
+                            for (int i = 0; i < size; i++) {
+                                hashEqExpr.add(new EqualTo(leftSlots.get(i), rightSlots.get(i)));
+                            }
+                            return new LogicalJoin(JoinType.INNER_JOIN, hashEqExpr,
+                                    join.getOtherJoinConjuncts(), join.left(), join.right());

Review Comment:
   we put all join condition into other join conjuncts when do bind



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSlotReference.java:
##########
@@ -111,19 +114,41 @@ public List<Rule> buildRules() {
                     return new LogicalFilter<>(boundPredicates, filter.child());
                 })
             ),
-            RuleType.BINDING_JOIN_SLOT.build(
-                logicalJoin().when(Plan::canBind).thenApply(ctx -> {
-                    LogicalJoin<GroupPlan, GroupPlan> join = ctx.root;
-                    List<Expression> cond = join.getOtherJoinConjuncts().stream()
-                            .map(expr -> bind(expr, join.children(), join, ctx.cascadesContext))
-                            .collect(Collectors.toList());
-                    List<Expression> hashJoinConjuncts = join.getHashJoinConjuncts().stream()
-                            .map(expr -> bind(expr, join.children(), join, ctx.cascadesContext))
-                            .collect(Collectors.toList());
-                    return new LogicalJoin<>(join.getJoinType(),
-                            hashJoinConjuncts, cond, join.left(), join.right());
-                })
-            ),
+                RuleType.BINDING_JOIN_SLOT.build(

Review Comment:
   this file use 4 spaces as continuation indent



-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] hello-stephen commented on pull request #14784: [feature](nereids) Support `using join` syntax

Posted by GitBox <gi...@apache.org>.
hello-stephen commented on PR #14784:
URL: https://github.com/apache/doris/pull/14784#issuecomment-1336082758

   TeamCity pipeline, clickbench performance test result:
    the sum of best hot time: 35.12 seconds
    load time: 468 seconds
    storage size: 17123356257 Bytes
    https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/tmp/20221203054435_clickbench_pr_57119.html


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #14784: [feature](nereids) Support `using join` syntax

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #14784:
URL: https://github.com/apache/doris/pull/14784#issuecomment-1340807283

   PR approved by anyone and no changes requested.


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #14784: [feature](nereids) Support `using join` syntax

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #14784:
URL: https://github.com/apache/doris/pull/14784#issuecomment-1340807222

   PR approved by at least one committer and no changes requested.


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #14784: [feature](nereids) Support `using join` syntax

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #14784:
URL: https://github.com/apache/doris/pull/14784#issuecomment-1342177905

   PR approved by at least one committer and no changes requested.


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org