You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by vl...@apache.org on 2019/12/29 11:38:41 UTC

[calcite] branch master updated (30bb98f -> 49cb002)

This is an automated email from the ASF dual-hosted git repository.

vladimirsitnikov pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git.


 discard 30bb98f  [CALCITE-3643] Prevent matching JoinCommuteRule when both inputs are the same
     new 49cb002  [CALCITE-3643] Prevent matching JoinCommuteRule when both inputs are the same

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (30bb98f)
            \
             N -- N -- N   refs/heads/master (49cb002)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 core/src/main/java/org/apache/calcite/rel/rules/JoinCommuteRule.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


[calcite] 01/01: [CALCITE-3643] Prevent matching JoinCommuteRule when both inputs are the same

Posted by vl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vladimirsitnikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit 49cb002479abdf0a3d95bcebc1ca424d52adbf40
Author: Vladimir Sitnikov <si...@gmail.com>
AuthorDate: Sun Dec 29 13:32:50 2019 +0300

    [CALCITE-3643] Prevent matching JoinCommuteRule when both inputs are the same
    
    =($0, $1) and =($1, $1) are equivalent, however adding that permutation
    increases search space.
---
 .../java/org/apache/calcite/rel/rules/JoinCommuteRule.java | 14 ++++++++------
 core/src/test/resources/sql/join.iq                        |  2 +-
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/rel/rules/JoinCommuteRule.java b/core/src/main/java/org/apache/calcite/rel/rules/JoinCommuteRule.java
index fe6f347..560a3fb 100644
--- a/core/src/main/java/org/apache/calcite/rel/rules/JoinCommuteRule.java
+++ b/core/src/main/java/org/apache/calcite/rel/rules/JoinCommuteRule.java
@@ -38,6 +38,7 @@ import org.apache.calcite.tools.RelBuilderFactory;
 import com.google.common.collect.ImmutableList;
 
 import java.util.List;
+import java.util.function.Predicate;
 
 /**
  * Planner rule that permutes the inputs to a
@@ -67,7 +68,13 @@ public class JoinCommuteRule extends RelOptRule {
    */
   public JoinCommuteRule(Class<? extends Join> clazz,
       RelBuilderFactory relBuilderFactory, boolean swapOuter) {
-    super(operand(clazz, any()), relBuilderFactory, null);
+    // FIXME Enable this rule for joins with system fields
+    super(
+        operandJ(clazz, null,
+            (Predicate<Join>) j -> j.getLeft().getId() != j.getRight().getId()
+                && j.getSystemFieldList().isEmpty(),
+            any()),
+        relBuilderFactory, null);
     this.swapOuter = swapOuter;
   }
 
@@ -143,11 +150,6 @@ public class JoinCommuteRule extends RelOptRule {
   public void onMatch(final RelOptRuleCall call) {
     Join join = call.rel(0);
 
-    if (!join.getSystemFieldList().isEmpty()) {
-      // FIXME Enable this rule for joins with system fields
-      return;
-    }
-
     final RelNode swapped = swap(join, this.swapOuter, call.builder());
     if (swapped == null) {
       return;
diff --git a/core/src/test/resources/sql/join.iq b/core/src/test/resources/sql/join.iq
index e771332..a798890 100644
--- a/core/src/test/resources/sql/join.iq
+++ b/core/src/test/resources/sql/join.iq
@@ -198,7 +198,7 @@ EnumerableCalc(expr#0..1=[{inputs}], DEPTNO=[$t1], ENAME=[$t0])
     EnumerableHashJoin(condition=[=($2, $4)], joinType=[inner])
       EnumerableCalc(expr#0..7=[{inputs}], expr#8=[10], expr#9=[+($t7, $t8)], proj#0..1=[{exprs}], $f8=[$t9])
         EnumerableTableScan(table=[[scott, EMP]])
-      EnumerableCalc(expr#0..3=[{inputs}], expr#4=[+($t3, $t1)], expr#5=[CAST($t4):INTEGER], DEPTNO=[$t3], $f16=[$t5])
+      EnumerableCalc(expr#0..3=[{inputs}], expr#4=[+($t1, $t3)], expr#5=[CAST($t4):INTEGER], DEPTNO=[$t3], $f16=[$t5])
         EnumerableHashJoin(condition=[=($1, $3)], joinType=[inner])
           EnumerableCalc(expr#0..7=[{inputs}], EMPNO=[$t0], DEPTNO=[$t7])
             EnumerableTableScan(table=[[scott, EMP]])