You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by zs...@apache.org on 2022/01/24 10:33:22 UTC
[ignite] branch sql-calcite updated: IGNITE-16333 Calcite. IgniteProject need to be initialized with single distribution - Fixes #9749.
This is an automated email from the ASF dual-hosted git repository.
zstan pushed a commit to branch sql-calcite
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/sql-calcite by this push:
new 4f2d8b2 IGNITE-16333 Calcite. IgniteProject need to be initialized with single distribution - Fixes #9749.
4f2d8b2 is described below
commit 4f2d8b2e008be3c52a9acd82c2d7812dfcaeefd3
Author: zstan <st...@gmail.com>
AuthorDate: Mon Jan 24 13:31:42 2022 +0300
IGNITE-16333 Calcite. IgniteProject need to be initialized with single distribution - Fixes #9749.
Signed-off-by: zstan <st...@gmail.com>
---
.../query/calcite/prepare/PlannerPhase.java | 3 ++-
.../query/calcite/rule/FilterConverterRule.java | 5 +++--
.../query/calcite/rule/ProjectConverterRule.java | 20 +++++++++++++++++++-
.../calcite/planner/SortAggregatePlannerTest.java | 13 +++++++++----
4 files changed, 33 insertions(+), 8 deletions(-)
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 1d40894..7e368a4 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
@@ -219,10 +219,11 @@ public enum PlannerPhase {
LogicalOrToUnionRule.INSTANCE,
+ // TODO: https://issues.apache.org/jira/browse/IGNITE-16334 join rules ordering is significant here.
+ MergeJoinConverterRule.INSTANCE,
CorrelatedNestedLoopJoinRule.INSTANCE,
CorrelateToNestedLoopRule.INSTANCE,
NestedLoopJoinConverterRule.INSTANCE,
- MergeJoinConverterRule.INSTANCE,
ValuesConverterRule.INSTANCE,
LogicalScanConverterRule.INDEX_SCAN,
diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/rule/FilterConverterRule.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/rule/FilterConverterRule.java
index 009316f..78dc70e 100644
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/rule/FilterConverterRule.java
+++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/rule/FilterConverterRule.java
@@ -48,8 +48,9 @@ public class FilterConverterRule extends AbstractIgniteConverterRule<LogicalFilt
/** {@inheritDoc} */
@Override protected PhysicalNode convert(RelOptPlanner planner, RelMetadataQuery mq, LogicalFilter rel) {
RelOptCluster cluster = rel.getCluster();
- RelTraitSet traits = rel.getTraitSet()
- .replace(IgniteConvention.INSTANCE)
+
+ RelTraitSet traits = cluster
+ .traitSetOf(IgniteConvention.INSTANCE)
.replace(IgniteDistributions.single());
Set<CorrelationId> corrIds = RexUtils.extractCorrelationIds(rel.getCondition());
diff --git a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/rule/ProjectConverterRule.java b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/rule/ProjectConverterRule.java
index cbe65d3..427398ef 100644
--- a/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/rule/ProjectConverterRule.java
+++ b/modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/rule/ProjectConverterRule.java
@@ -17,16 +17,22 @@
package org.apache.ignite.internal.processors.query.calcite.rule;
+import java.util.Set;
import org.apache.calcite.plan.RelOptCluster;
import org.apache.calcite.plan.RelOptPlanner;
import org.apache.calcite.plan.RelOptRule;
import org.apache.calcite.plan.RelTraitSet;
import org.apache.calcite.rel.PhysicalNode;
import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.CorrelationId;
import org.apache.calcite.rel.logical.LogicalProject;
import org.apache.calcite.rel.metadata.RelMetadataQuery;
import org.apache.ignite.internal.processors.query.calcite.rel.IgniteConvention;
import org.apache.ignite.internal.processors.query.calcite.rel.IgniteProject;
+import org.apache.ignite.internal.processors.query.calcite.trait.CorrelationTrait;
+import org.apache.ignite.internal.processors.query.calcite.trait.IgniteDistributions;
+import org.apache.ignite.internal.processors.query.calcite.trait.RewindabilityTrait;
+import org.apache.ignite.internal.processors.query.calcite.util.RexUtils;
/**
*
@@ -43,7 +49,19 @@ public class ProjectConverterRule extends AbstractIgniteConverterRule<LogicalPro
/** {@inheritDoc} */
@Override protected PhysicalNode convert(RelOptPlanner planner, RelMetadataQuery mq, LogicalProject rel) {
RelOptCluster cluster = rel.getCluster();
- RelTraitSet traits = cluster.traitSetOf(IgniteConvention.INSTANCE);
+
+ RelTraitSet traits = cluster
+ .traitSetOf(IgniteConvention.INSTANCE)
+ .replace(IgniteDistributions.single());
+
+ Set<CorrelationId> corrIds = RexUtils.extractCorrelationIds(rel.getProjects());
+
+ if (!corrIds.isEmpty()) {
+ traits = traits
+ .replace(CorrelationTrait.correlations(corrIds))
+ .replace(RewindabilityTrait.REWINDABLE);
+ }
+
RelNode input = convert(rel.getInput(), traits);
return new IgniteProject(cluster, traits, input, rel.getProjects(), rel.getRowType());
diff --git a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/SortAggregatePlannerTest.java b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/SortAggregatePlannerTest.java
index c770872..1384de7 100644
--- a/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/SortAggregatePlannerTest.java
+++ b/modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/planner/SortAggregatePlannerTest.java
@@ -30,6 +30,7 @@ import org.apache.ignite.internal.processors.query.calcite.rel.IgniteCorrelatedN
import org.apache.ignite.internal.processors.query.calcite.rel.IgniteLimit;
import org.apache.ignite.internal.processors.query.calcite.rel.IgniteRel;
import org.apache.ignite.internal.processors.query.calcite.rel.IgniteSort;
+import org.apache.ignite.internal.processors.query.calcite.rel.IgniteTableScan;
import org.apache.ignite.internal.processors.query.calcite.rel.agg.IgniteReduceSortAggregate;
import org.apache.ignite.internal.processors.query.calcite.rel.agg.IgniteSingleSortAggregate;
import org.apache.ignite.internal.processors.query.calcite.schema.IgniteSchema;
@@ -85,13 +86,17 @@ public class SortAggregatePlannerTest extends AbstractAggregatePlannerTest {
IgniteRel phys = physicalPlan(
sql,
publicSchema,
- "HashSingleAggregateConverterRule", "HashMapReduceAggregateConverterRule",
- "LogicalTableScanConverterRule"
+ "NestedLoopJoinConverter",
+ "CorrelatedNestedLoopJoin",
+ "CorrelateToNestedLoopRule",
+ "HashSingleAggregateConverterRule",
+ "HashMapReduceAggregateConverterRule"
);
- assertNull(
+ assertTrue(
"Invalid plan\n" + RelOptUtil.toString(phys),
- findFirstNode(phys, byClass(IgniteSort.class))
+ findFirstNode(phys, byClass(IgniteSort.class)) == null &&
+ findFirstNode(phys, byClass(IgniteTableScan.class)) == null
);
}