You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by hy...@apache.org on 2019/12/10 04:44:02 UTC
[calcite] branch master updated: [CALCITE-3576] Remove enumerable
convention check in FilterIntoJoinRule
This is an automated email from the ASF dual-hosted git repository.
hyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/master by this push:
new abb4fef [CALCITE-3576] Remove enumerable convention check in FilterIntoJoinRule
abb4fef is described below
commit abb4fef8eda2d26cc14f787c5393caac75a35efb
Author: Haisheng Yuan <h....@alibaba-inc.com>
AuthorDate: Fri Dec 6 18:38:28 2019 -0800
[CALCITE-3576] Remove enumerable convention check in FilterIntoJoinRule
---
.../org/apache/calcite/rel/rules/FilterJoinRule.java | 16 ++++------------
core/src/test/java/org/apache/calcite/test/JdbcTest.java | 6 +++---
.../calcite/test/enumerable/EnumerableHashJoinTest.java | 6 +++---
core/src/test/resources/sql/join.iq | 6 +++---
core/src/test/resources/sql/misc.iq | 8 ++++----
core/src/test/resources/sql/sub-query.iq | 9 ++++-----
6 files changed, 21 insertions(+), 30 deletions(-)
diff --git a/core/src/main/java/org/apache/calcite/rel/rules/FilterJoinRule.java b/core/src/main/java/org/apache/calcite/rel/rules/FilterJoinRule.java
index c24a282..635bd1d 100644
--- a/core/src/main/java/org/apache/calcite/rel/rules/FilterJoinRule.java
+++ b/core/src/main/java/org/apache/calcite/rel/rules/FilterJoinRule.java
@@ -16,7 +16,6 @@
*/
package org.apache.calcite.rel.rules;
-import org.apache.calcite.adapter.enumerable.EnumerableConvention;
import org.apache.calcite.plan.RelOptRule;
import org.apache.calcite.plan.RelOptRuleCall;
import org.apache.calcite.plan.RelOptRuleOperand;
@@ -53,28 +52,21 @@ public abstract class FilterJoinRule extends RelOptRule {
* will be pushed into the ON clause. */
public static final Predicate TRUE_PREDICATE = (join, joinType, exp) -> true;
- /** Predicate that returns true if the join is not Enumerable convention,
- * will be replaced by {@link #TRUE_PREDICATE} once enumerable join supports
- * non-equi join. */
- // to be removed before 1.22.0
- private static final Predicate NOT_ENUMERABLE = (join, joinType, exp) ->
- join.getConvention() != EnumerableConvention.INSTANCE;
-
/** Rule that pushes predicates from a Filter into the Join below them. */
public static final FilterJoinRule FILTER_ON_JOIN =
new FilterIntoJoinRule(true, RelFactories.LOGICAL_BUILDER,
- NOT_ENUMERABLE);
+ TRUE_PREDICATE);
/** Dumber version of {@link #FILTER_ON_JOIN}. Not intended for production
* use, but keeps some tests working for which {@code FILTER_ON_JOIN} is too
* smart. */
public static final FilterJoinRule DUMB_FILTER_ON_JOIN =
new FilterIntoJoinRule(false, RelFactories.LOGICAL_BUILDER,
- NOT_ENUMERABLE);
+ TRUE_PREDICATE);
/** Rule that pushes predicates in a Join into the inputs to the join. */
public static final FilterJoinRule JOIN =
- new JoinConditionPushRule(RelFactories.LOGICAL_BUILDER, NOT_ENUMERABLE);
+ new JoinConditionPushRule(RelFactories.LOGICAL_BUILDER, TRUE_PREDICATE);
/** Whether to try to strengthen join-type. */
private final boolean smart;
@@ -106,7 +98,7 @@ public abstract class FilterJoinRule extends RelOptRule {
boolean smart, RelFactories.FilterFactory filterFactory,
RelFactories.ProjectFactory projectFactory) {
this(operand, id, smart, RelBuilder.proto(filterFactory, projectFactory),
- NOT_ENUMERABLE);
+ TRUE_PREDICATE);
}
/**
diff --git a/core/src/test/java/org/apache/calcite/test/JdbcTest.java b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
index e63baac..aba424b 100644
--- a/core/src/test/java/org/apache/calcite/test/JdbcTest.java
+++ b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
@@ -2705,10 +2705,10 @@ public class JdbcTest {
+ "where emps.deptno = sn.id and sn.desc = 'SameName' group by empno, desc")
.explainContains("EnumerableCalc(expr#0..1=[{inputs}], EMPNO=[$t1], DESC=[$t0])\n"
+ " EnumerableAggregate(group=[{1, 2}])\n"
- + " EnumerableCalc(expr#0..3=[{inputs}], expr#4=[CAST($t3):INTEGER NOT NULL], expr#5=[=($t4, $t0)], expr#6=['SameName'], expr#7=[=($t1, $t6)], expr#8=[AND($t5, $t7)], proj#0..3=[{exprs}], $condition=[$t8])\n"
- + " EnumerableHashJoin(condition=[true], joinType=[inner])\n"
+ + " EnumerableHashJoin(condition=[=(CAST($3):INTEGER NOT NULL, $0)], joinType=[inner])\n"
+ + " EnumerableCalc(expr#0..1=[{inputs}], expr#2=['SameName'], expr#3=[=($t1, $t2)], proj#0..1=[{exprs}], $condition=[$t3])\n"
+ " EnumerableValues(tuples=[[{ 10, 'SameName' }]])\n"
- + " EnumerableTableScan(table=[[SALES, EMPS]])\n")
+ + " EnumerableTableScan(table=[[SALES, EMPS]])\n")
.returns("EMPNO=1; DESC=SameName\n");
}
diff --git a/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableHashJoinTest.java b/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableHashJoinTest.java
index 0c6a480..0d562e2 100644
--- a/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableHashJoinTest.java
+++ b/core/src/test/java/org/apache/calcite/test/enumerable/EnumerableHashJoinTest.java
@@ -54,9 +54,9 @@ public class EnumerableHashJoinTest {
.query(
"select e.empid, e.name, d.name as dept from emps e join depts d"
+ " on e.deptno=d.deptno and e.empid<150 and e.empid>d.deptno")
- .explainContains("EnumerableCalc(expr#0..4=[{inputs}], expr#5=[>($t0,"
- + " $t3)], empid=[$t0], name=[$t2], dept=[$t4], $condition=[$t5])\n"
- + " EnumerableHashJoin(condition=[=($1, $3)], joinType=[inner])\n"
+ .explainContains(
+ "EnumerableCalc(expr#0..4=[{inputs}], empid=[$t0], name=[$t2], dept=[$t4])\n"
+ + " EnumerableHashJoin(condition=[AND(=($1, $3), >($0, $3))], joinType=[inner])\n"
+ " EnumerableCalc(expr#0..4=[{inputs}], expr#5=[150], "
+ "expr#6=[<($t0, $t5)], proj#0..2=[{exprs}], $condition=[$t6])\n"
+ " EnumerableTableScan(table=[[s, emps]])\n"
diff --git a/core/src/test/resources/sql/join.iq b/core/src/test/resources/sql/join.iq
index 7971d6e..d27a5de 100644
--- a/core/src/test/resources/sql/join.iq
+++ b/core/src/test/resources/sql/join.iq
@@ -37,8 +37,9 @@ on emp.deptno = dept.deptno or emp.ename = dept.dname;
!ok
# As an INNER join, it can be executed as an equi-join followed by a filter
-EnumerableCalc(expr#0..4=[{inputs}], expr#5=[=($t1, $t3)], expr#6=[CAST($t0):CHAR(11) NOT NULL], expr#7=[=($t6, $t4)], expr#8=[OR($t5, $t7)], proj#0..4=[{exprs}], $condition=[$t8])
- EnumerableHashJoin(condition=[true], joinType=[inner])
+EnumerableCalc(expr#0..4=[{inputs}], ENAME=[$t2], DEPTNO=[$t3], GENDER=[$t4], DEPTNO0=[$t0], DNAME=[$t1])
+ EnumerableHashJoin(condition=[OR(=($3, $0), =(CAST($2):CHAR(11) NOT NULL, $1))], joinType=[inner])
+ EnumerableValues(tuples=[[{ 10, 'Sales ' }, { 20, 'Marketing ' }, { 30, 'Engineering' }, { 40, 'Empty ' }]])
EnumerableUnion(all=[true])
EnumerableCalc(expr#0=[{inputs}], expr#1=['Jane'], expr#2=[10], expr#3=['F'], EXPR$0=[$t1], EXPR$1=[$t2], EXPR$2=[$t3])
EnumerableValues(tuples=[[{ 0 }]])
@@ -58,7 +59,6 @@ EnumerableCalc(expr#0..4=[{inputs}], expr#5=[=($t1, $t3)], expr#6=[CAST($t0):CHA
EnumerableValues(tuples=[[{ 0 }]])
EnumerableCalc(expr#0=[{inputs}], expr#1=['Wilma'], expr#2=[null:INTEGER], expr#3=['F'], EXPR$0=[$t1], EXPR$1=[$t2], EXPR$2=[$t3])
EnumerableValues(tuples=[[{ 0 }]])
- EnumerableValues(tuples=[[{ 10, 'Sales ' }, { 20, 'Marketing ' }, { 30, 'Engineering' }, { 40, 'Empty ' }]])
!plan
# Now the same, but LEFT join
diff --git a/core/src/test/resources/sql/misc.iq b/core/src/test/resources/sql/misc.iq
index 777eaa4..b481a0c 100644
--- a/core/src/test/resources/sql/misc.iq
+++ b/core/src/test/resources/sql/misc.iq
@@ -290,8 +290,8 @@ and e."name" <> d."name";
(3 rows)
!ok
-EnumerableCalc(expr#0..4=[{inputs}], expr#5=[CAST($t2):VARCHAR], expr#6=[CAST($t4):VARCHAR], expr#7=[<>($t5, $t6)], empid=[$t0], name=[$t4], name0=[$t2], $condition=[$t7])
- EnumerableHashJoin(condition=[=($1, $3)], joinType=[inner])
+EnumerableCalc(expr#0..4=[{inputs}], empid=[$t0], name=[$t4], name0=[$t2])
+ EnumerableHashJoin(condition=[AND(=($1, $3), <>(CAST($2):VARCHAR, CAST($4):VARCHAR))], joinType=[inner])
EnumerableCalc(expr#0..4=[{inputs}], proj#0..2=[{exprs}])
EnumerableTableScan(table=[[hr, emps]])
EnumerableCalc(expr#0..3=[{inputs}], proj#0..1=[{exprs}])
@@ -314,8 +314,8 @@ and e."name" <> d."name";
(3 rows)
!ok
-EnumerableCalc(expr#0..4=[{inputs}], expr#5=[CAST($t2):VARCHAR], expr#6=[CAST($t4):VARCHAR], expr#7=[<>($t5, $t6)], empid=[$t0], name=[$t4], name0=[$t2], $condition=[$t7])
- EnumerableHashJoin(condition=[=($1, $3)], joinType=[inner])
+EnumerableCalc(expr#0..4=[{inputs}], empid=[$t0], name=[$t4], name0=[$t2])
+ EnumerableHashJoin(condition=[AND(=($1, $3), <>(CAST($2):VARCHAR, CAST($4):VARCHAR))], joinType=[inner])
EnumerableCalc(expr#0..4=[{inputs}], proj#0..2=[{exprs}])
EnumerableTableScan(table=[[hr, emps]])
EnumerableCalc(expr#0..3=[{inputs}], proj#0..1=[{exprs}])
diff --git a/core/src/test/resources/sql/sub-query.iq b/core/src/test/resources/sql/sub-query.iq
index 52ae2ed..e7c8064 100644
--- a/core/src/test/resources/sql/sub-query.iq
+++ b/core/src/test/resources/sql/sub-query.iq
@@ -2055,11 +2055,10 @@ EnumerableAggregate(group=[{}], C=[COUNT()])
EnumerableTableScan(table=[[scott, EMP]])
EnumerableCalc(expr#0..2=[{inputs}], expr#3=[1:BIGINT], expr#4=[IS NOT NULL($t1)], DNAME=[$t1], $f1=[$t3], $f2=[$t3], $condition=[$t4])
EnumerableTableScan(table=[[scott, DEPT]])
- EnumerableCalc(expr#0..4=[{inputs}], DEPTNO=[$t2], i=[$t3], DNAME=[$t4], SAL=[$t0])
- EnumerableHashJoin(condition=[=($1, $2)], joinType=[inner])
- EnumerableCalc(expr#0=[{inputs}], expr#1=[100], expr#2=[+($t0, $t1)], SAL=[$t0], $f1=[$t2])
- EnumerableAggregate(group=[{5}])
- EnumerableTableScan(table=[[scott, EMP]])
+ EnumerableCalc(expr#0..3=[{inputs}], DEPTNO=[$t1], i=[$t2], DNAME=[$t3], SAL=[$t0])
+ EnumerableHashJoin(condition=[=(+($0, 100), $1)], joinType=[inner])
+ EnumerableAggregate(group=[{5}])
+ EnumerableTableScan(table=[[scott, EMP]])
EnumerableCalc(expr#0..2=[{inputs}], expr#3=[true], expr#4=[IS NOT NULL($t1)], DEPTNO=[$t0], i=[$t3], DNAME=[$t1], $condition=[$t4])
EnumerableTableScan(table=[[scott, DEPT]])
!plan