Skip to content

Commit

Permalink
Kyligence#55 OlapJoinPushThroughJoinRule - fix join type (Kyligence#54)
Browse files Browse the repository at this point in the history
* OLAPJoinPushThroughJoinRule - fix join type

* version bump to r7

* sytle

* correct checking
  • Loading branch information
lxian authored Aug 5, 2019
1 parent ba061e5 commit 2b344d4
Show file tree
Hide file tree
Showing 22 changed files with 56 additions and 42 deletions.
4 changes: 2 additions & 2 deletions cassandra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite</artifactId>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
</parent>

<artifactId>calcite-cassandra</artifactId>
<packaging>jar</packaging>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
<name>Calcite Cassandra</name>
<description>Cassandra adapter for Calcite</description>

Expand Down
4 changes: 2 additions & 2 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite</artifactId>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
</parent>

<artifactId>calcite-core</artifactId>
<packaging>jar</packaging>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
<name>Calcite Core</name>
<description>Core Calcite APIs and engine.</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.calcite.plan.RelOptUtil;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.core.Join;
import org.apache.calcite.rel.core.JoinRelType;
import org.apache.calcite.rel.core.RelFactories;
import org.apache.calcite.rel.core.TableScan;
import org.apache.calcite.rel.logical.LogicalJoin;
Expand Down Expand Up @@ -106,6 +107,12 @@ private void onMatchRight(RelOptRuleCall call) {
// return;
// }

// right join cannot be pushed through inner
if (topJoin.getJoinType() == JoinRelType.RIGHT
&& bottomJoin.getJoinType() == JoinRelType.INNER) {
return;
}

// Split the condition of topJoin into a conjunction. Each of the
// parts that does not use columns from B can be pushed down.
final List<RexNode> intersecting = new ArrayList<>();
Expand Down Expand Up @@ -142,7 +149,7 @@ private void onMatchRight(RelOptRuleCall call) {
RexNode newBottomCondition = RexUtil.composeConjunction(rexBuilder,
newBottomList, false);
final Join newBottomJoin = bottomJoin.copy(bottomJoin.getTraitSet(),
newBottomCondition, relA, relC, bottomJoin.getJoinType(), bottomJoin.isSemiJoinDone());
newBottomCondition, relA, relC, topJoin.getJoinType(), bottomJoin.isSemiJoinDone());

// target: | A | C | B |
// source: | A | B | C |
Expand All @@ -157,7 +164,7 @@ private void onMatchRight(RelOptRuleCall call) {
RexNode newTopCondition = RexUtil.composeConjunction(rexBuilder, newTopList, false);
@SuppressWarnings("SuspiciousNameCombination")
final Join newTopJoin = topJoin.copy(topJoin.getTraitSet(), newTopCondition, newBottomJoin,
relB, topJoin.getJoinType(), topJoin.isSemiJoinDone());
relB, bottomJoin.getJoinType(), topJoin.isSemiJoinDone());

assert !Mappings.isIdentity(topMapping);
final RelBuilder relBuilder = call.builder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.calcite.plan.RelOptUtil;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.core.Join;
import org.apache.calcite.rel.core.JoinRelType;
import org.apache.calcite.rel.core.Project;
import org.apache.calcite.rel.core.RelFactories;
import org.apache.calcite.rel.core.TableScan;
Expand Down Expand Up @@ -136,6 +137,12 @@ private void onMatchRight(RelOptRuleCall call) {
// return;
// }

// right join cannot be pushed through inner
if (topJoin.getJoinType() == JoinRelType.RIGHT
&& bottomJoin.getJoinType() == JoinRelType.INNER) {
return;
}

// Split the condition of topJoin into a conjunction. Each of the
// parts that does not use columns from B can be pushed down.
final List<RexNode> intersecting = new ArrayList<>();
Expand Down Expand Up @@ -168,7 +175,7 @@ private void onMatchRight(RelOptRuleCall call) {
final RexBuilder rexBuilder = cluster.getRexBuilder();
RexNode newBottomCondition = RexUtil.composeConjunction(rexBuilder, newBottomList, false);
final Join newBottomJoin = bottomJoin.copy(bottomJoin.getTraitSet(),
newBottomCondition, relA, relC, bottomJoin.getJoinType(), bottomJoin.isSemiJoinDone());
newBottomCondition, relA, relC, topJoin.getJoinType(), bottomJoin.isSemiJoinDone());

// target: | A | C | B |
// source: | A | B | C |
Expand All @@ -183,7 +190,7 @@ private void onMatchRight(RelOptRuleCall call) {
RexNode newTopCondition = RexUtil.composeConjunction(rexBuilder, newTopList, false);
@SuppressWarnings("SuspiciousNameCombination")
final Join newTopJoin = topJoin.copy(topJoin.getTraitSet(), newTopCondition,
newBottomJoin, relB, topJoin.getJoinType(), topJoin.isSemiJoinDone());
newBottomJoin, relB, bottomJoin.getJoinType(), topJoin.isSemiJoinDone());

assert !Mappings.isIdentity(thruProjectMapping);
final RelBuilder relBuilder = call.builder();
Expand Down
4 changes: 2 additions & 2 deletions druid/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite</artifactId>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
</parent>

<artifactId>calcite-druid</artifactId>
<packaging>jar</packaging>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
<name>Calcite Druid</name>
<description>Druid adapter for Calcite</description>

Expand Down
4 changes: 2 additions & 2 deletions elasticsearch2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite</artifactId>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
</parent>

<artifactId>calcite-elasticsearch2</artifactId>
<packaging>jar</packaging>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
<name>Calcite Elasticsearch</name>
<description>Elasticsearch adapter for Calcite</description>

Expand Down
4 changes: 2 additions & 2 deletions elasticsearch5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite</artifactId>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
</parent>

<artifactId>calcite-elasticsearch5</artifactId>
<packaging>jar</packaging>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
<name>Calcite Elasticsearch5</name>
<description>Elasticsearch5 adapter for Calcite</description>

Expand Down
4 changes: 2 additions & 2 deletions example/csv/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite-example</artifactId>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
</parent>

<artifactId>calcite-example-csv</artifactId>
<packaging>jar</packaging>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
<name>Calcite Example CSV</name>
<description>An example Calcite provider that reads CSV files</description>

Expand Down
4 changes: 2 additions & 2 deletions example/function/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite-example</artifactId>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
</parent>

<artifactId>calcite-example-function</artifactId>
<packaging>jar</packaging>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
<name>Calcite Example Function</name>
<description>Examples of user-defined Calcite functions</description>

Expand Down
4 changes: 2 additions & 2 deletions example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite</artifactId>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
</parent>

<!-- The basics. -->
<artifactId>calcite-example</artifactId>
<packaging>pom</packaging>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
<name>Calcite Examples</name>
<description>Calcite examples</description>

Expand Down
4 changes: 2 additions & 2 deletions file/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite</artifactId>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
</parent>

<!-- The basics. -->
<artifactId>calcite-file</artifactId>
<packaging>jar</packaging>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
<name>Calcite File</name>
<description>Calcite provider that reads files and URIs</description>

Expand Down
4 changes: 2 additions & 2 deletions geode/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite</artifactId>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
</parent>

<artifactId>calcite-geode</artifactId>
<packaging>jar</packaging>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
<name>Calcite Geode</name>
<description>Geode adapter for Calcite</description>

Expand Down
4 changes: 2 additions & 2 deletions linq4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite</artifactId>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
</parent>

<artifactId>calcite-linq4j</artifactId>
<packaging>jar</packaging>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
<name>Calcite Linq4j</name>
<description>Calcite APIs for LINQ (Language-Integrated Query) in Java</description>

Expand Down
4 changes: 2 additions & 2 deletions mongodb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite</artifactId>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
</parent>

<artifactId>calcite-mongodb</artifactId>
<packaging>jar</packaging>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
<name>Calcite MongoDB</name>
<description>MongoDB adapter for Calcite</description>

Expand Down
4 changes: 2 additions & 2 deletions pig/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite</artifactId>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
</parent>

<artifactId>calcite-pig</artifactId>
<packaging>jar</packaging>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
<name>Calcite Pig</name>
<description>Pig adapter for Calcite</description>

Expand Down
4 changes: 2 additions & 2 deletions piglet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite</artifactId>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
</parent>

<artifactId>calcite-piglet</artifactId>
<packaging>jar</packaging>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
<name>Calcite Piglet</name>
<description>Pig-like language built on top of Calcite algebra</description>

Expand Down
4 changes: 2 additions & 2 deletions plus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite</artifactId>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
</parent>

<artifactId>calcite-plus</artifactId>
<packaging>jar</packaging>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
<name>Calcite Plus</name>
<description>Miscellaneous extras for Calcite</description>

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ limitations under the License.
<groupId>org.apache.calcite</groupId>
<artifactId>calcite</artifactId>
<packaging>pom</packaging>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>

<!-- More project information. -->
<name>Calcite</name>
Expand Down
4 changes: 2 additions & 2 deletions server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite</artifactId>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
</parent>

<artifactId>calcite-server</artifactId>
<packaging>jar</packaging>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
<name>Calcite Server</name>
<description>Calcite Server</description>

Expand Down
4 changes: 2 additions & 2 deletions spark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite</artifactId>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
</parent>

<artifactId>calcite-spark</artifactId>
<packaging>jar</packaging>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
<name>Calcite Spark</name>

<properties>
Expand Down
4 changes: 2 additions & 2 deletions splunk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite</artifactId>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
</parent>

<artifactId>calcite-splunk</artifactId>
<packaging>jar</packaging>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
<name>Calcite Splunk</name>
<description>Splunk adapter for Calcite; also a JDBC driver for Splunk</description>

Expand Down
2 changes: 1 addition & 1 deletion ubenchmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.
<parent>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite</artifactId>
<version>1.16.0-kylin-4.x-r6</version>
<version>1.16.0-kylin-4.x-r7</version>
</parent>

<properties>
Expand Down

0 comments on commit 2b344d4

Please sign in to comment.