You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by am...@apache.org on 2020/06/17 16:08:51 UTC
[ignite] branch ignite-12747 updated: Revert unrelated changes. Add
SemiJoin rules. Add tests.
This is an automated email from the ASF dual-hosted git repository.
amashenkov pushed a commit to branch ignite-12747
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/ignite-12747 by this push:
new d5caf03 Revert unrelated changes. Add SemiJoin rules. Add tests.
d5caf03 is described below
commit d5caf034b73633929e7607995001a0af27064c04
Author: Andrew V. Mashenkov <an...@gmail.com>
AuthorDate: Wed Jun 17 19:08:09 2020 +0300
Revert unrelated changes.
Add SemiJoin rules.
Add tests.
---
.../query/calcite/CalciteQueryProcessor.java | 1 -
.../query/calcite/prepare/PlannerPhase.java | 3 ++
.../calcite/rules/SubqueryRewriteRuleTest.java | 42 ++++++++++++++++++++--
3 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessor.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessor.java
index c123b87..3e83316 100644
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessor.java
+++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/CalciteQueryProcessor.java
@@ -67,7 +67,6 @@ public class CalciteQueryProcessor extends GridProcessorAdapter implements Query
.sqlToRelConverterConfig(SqlToRelConverter.configBuilder()
.withTrimUnusedFields(true)
.withDecorrelationEnabled(true)
-// .withExpand(false)
.build())
.parserConfig(SqlParser.configBuilder()
// Lexical configuration defines how identifiers are quoted, whether they are converted to upper or lower
diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/PlannerPhase.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/PlannerPhase.java
index dddf93b..307b2ad 100644
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/PlannerPhase.java
+++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/PlannerPhase.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.processors.query.calcite.prepare;
import org.apache.calcite.rel.rules.ProjectFilterTransposeRule;
+import org.apache.calcite.rel.rules.SemiJoinRule;
import org.apache.calcite.rel.rules.SortRemoveRule;
import org.apache.calcite.rel.rules.SubQueryRemoveRule;
import org.apache.calcite.rel.rules.UnionMergeRule;
@@ -73,6 +74,8 @@ public enum PlannerPhase {
JoinConverterRule.INSTANCE,
FilterJoinRule.PUSH_JOIN_CONDITION,
FilterJoinRule.FILTER_ON_JOIN,
+ SemiJoinRule.JOIN,
+ SemiJoinRule.PROJECT,
ProjectConverterRule.INSTANCE,
FilterConverterRule.INSTANCE,
LogicalFilterMergeRule.INSTANCE,
diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/rules/SubqueryRewriteRuleTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/rules/SubqueryRewriteRuleTest.java
index d42f431..aaf4bff 100644
--- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/rules/SubqueryRewriteRuleTest.java
+++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/rules/SubqueryRewriteRuleTest.java
@@ -29,6 +29,7 @@ import org.apache.ignite.internal.processors.query.QueryEngine;
import org.apache.ignite.internal.processors.query.calcite.QueryChecker;
import org.apache.ignite.internal.processors.query.calcite.util.Commons;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Ignore;
import org.junit.Test;
import static java.util.Arrays.asList;
@@ -199,18 +200,53 @@ public class SubqueryRewriteRuleTest extends GridCommonAbstractTest {
}
/**
- * Check subquery rewrite rule is applied for correlated query.
+ * Check subquery rewrite rule is applied for non-correlated query.
+ *
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testNonInToSemiJoinRule() throws Exception {
+ checkQuery("SELECT c_name\n" +
+ "FROM CUSTOMER\n" +
+ "WHERE c_countrykey NOT IN (SELECT s_countrykey FROM SUPPLIER)")
+ .and(QueryChecker.containsJoin("left"))
+ .and(QueryChecker.containsJoin("inner"))
+ .and(containsScan("PUBLIC", "CUSTOMER", "PK"))
+ .and(containsScan("PUBLIC", "SUPPLIER", "PK"))
+ .check();
+ }
+
+ /**
+ * Check subquery rewrite rule is applied for non-correlated query.
*
* @throws Exception If failed.
*/
+ @Ignore("https://issues.apache.org/jira/browse/IGNITE-13159")
@Test
- public void testNonInToSemiAntiJoinRule() throws Exception {
+ public void testNonAllToSemiAntiJoinRule() throws Exception {
checkQuery("SELECT c_name\n" +
"FROM CUSTOMER\n" +
"WHERE c_countrykey <> ALL (SELECT s_countrykey FROM SUPPLIER)")
.and(QueryChecker.containsJoin("anti"))
.and(containsScan("PUBLIC", "CUSTOMER", "PK"))
- .and(containsScan("PUBLIC", "ORDERS", "PK"))
+ .and(containsScan("PUBLIC", "SUPPLIER", "PK"))
+ .check();
+ }
+
+ /**
+ * Check subquery rewrite rule is applied for correlated query.
+ *
+ * @throws Exception If failed.
+ */
+ @Ignore("https://issues.apache.org/jira/browse/IGNITE-13159")
+ @Test
+ public void testNonInToSemiAntiJoinRule2() throws Exception {
+ checkQuery("SELECT c_name\n" +
+ "FROM CUSTOMER\n" +
+ "WHERE c_countrykey NOT IN (SELECT s_countrykey FROM SUPPLIER WHERE s_supkey = c_custkey)")
+ .and(QueryChecker.containsJoin("left"))
+ .and(containsScan("PUBLIC", "CUSTOMER", "PK"))
+ .and(containsScan("PUBLIC", "SUPPLIER", "PK"))
.check();
}