tledkov-gridgain commented on a change in pull request #8472:
URL: https://github.com/apache/ignite/pull/8472#discussion_r527682934
##########
File path:
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/PlannerTest.java
##########
@@ -2617,19 +2643,138 @@ public void testJoinPushExpressionRule() throws
Exception {
RelTraitSet desired = rel.getCluster().traitSet()
.replace(IgniteConvention.INSTANCE)
.replace(IgniteDistributions.single())
+ .replace(CorrelationTrait.UNCORRELATED)
.simplify();
RelNode phys = planner.transform(PlannerPhase.OPTIMIZATION,
desired, rel);
assertNotNull(phys);
- assertEquals("" +
- "IgniteCorrelatedNestedLoopJoin(condition=[=(CAST(+($0,
$1)):INTEGER, 2)], joinType=[inner])\n" +
- " IgniteTableScan(table=[[PUBLIC, DEPT]],
requiredColunms=[{0}])\n" +
- " IgniteTableScan(table=[[PUBLIC, EMP]],
filters=[=(CAST(+($cor3.DEPTNO, $t0)):INTEGER, 2)], requiredColunms=[{2}])\n",
+ assertEquals(
+ "Invalid plan:\n" + RelOptUtil.toString(phys),
+ "IgniteCorrelatedNestedLoopJoin(condition=[=(CAST(+($0,
$1)):INTEGER, 2)], joinType=[inner])\n" +
+ " IgniteTableScan(table=[[PUBLIC, DEPT]],
requiredColumns=[{0}])\n" +
+ " IgniteTableScan(table=[[PUBLIC, EMP]],
filters=[=(CAST(+($cor3.DEPTNO, $t0)):INTEGER, 2)], requiredColumns=[{2}])\n",
RelOptUtil.toString(phys));
}
}
+ /**
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testTableSpoolTest() throws Exception {
+ IgniteTypeFactory f = new IgniteTypeFactory(IgniteTypeSystem.INSTANCE);
+
+ TestTable t0 = new TestTable(
+ new RelDataTypeFactory.Builder(f)
+ .add("ID", f.createJavaType(Integer.class))
+ .add("JID", f.createJavaType(Integer.class))
+ .add("VAL", f.createJavaType(String.class))
+ .build()) {
+
+ @Override public IgniteDistribution distribution() {
+ return IgniteDistributions.affinity(0, "T0", "hash");
+ }
+ };
+
+ TestTable t1 = new TestTable(
+ new RelDataTypeFactory.Builder(f)
+ .add("ID", f.createJavaType(Integer.class))
+ .add("JID", f.createJavaType(Integer.class))
+ .add("VAL", f.createJavaType(String.class))
+ .build()) {
+
+ @Override public IgniteDistribution distribution() {
+ return IgniteDistributions.affinity(0, "T1", "hash");
+ }
+ };
+
+ IgniteSchema publicSchema = new IgniteSchema("PUBLIC");
+
+ publicSchema.addTable("T0", t0);
+ publicSchema.addTable("T1", t1);
+
+ SchemaPlus schema = createRootSchema(false)
+ .add("PUBLIC", publicSchema);
+
+ String sql = "select * " +
+ "from t0 " +
+ "join t1 on t0.jid = t1.jid ";
+
+ RelTraitDef<?>[] traitDefs = {
+ DistributionTraitDef.INSTANCE,
+ ConventionTraitDef.INSTANCE,
+ RelCollationTraitDef.INSTANCE,
+ RewindabilityTraitDef.INSTANCE,
+ CorrelationTraitDef.INSTANCE
+ };
+
+ PlanningContext ctx = PlanningContext.builder()
+ .localNodeId(F.first(nodes))
+ .originatingNodeId(F.first(nodes))
+ .parentContext(Contexts.empty())
+ .frameworkConfig(newConfigBuilder(FRAMEWORK_CONFIG)
+ .defaultSchema(schema)
+ .traitDefs(traitDefs)
+ .build())
+ .logger(log)
+ .query(sql)
+ .topologyVersion(AffinityTopologyVersion.NONE)
+ .build();
+
+ RelRoot relRoot;
+
+ try (IgnitePlanner planner = ctx.planner()) {
+ assertNotNull(planner);
+
+ String qry = ctx.query();
+
+ assertNotNull(qry);
+
+ // Parse
+ SqlNode sqlNode = planner.parse(qry);
+
+ // Validate
+ sqlNode = planner.validate(sqlNode);
+
+ // Convert to Relational operators graph
+ relRoot = planner.rel(sqlNode);
+
+ RelNode rel = relRoot.rel;
+
+ assertNotNull(rel);
+
+ // Transformation chain
+ RelTraitSet desired = rel.getCluster().traitSet()
+ .replace(IgniteConvention.INSTANCE)
+ .replace(IgniteDistributions.single())
+ .simplify();
+
+
planner.setDisabledRules(ImmutableSet.of("NestedLoopJoinConverter(in:NONE,out:IGNITE)"));
Review comment:
Now we have olny two join implementation: NL join that doesn't require
rewindable for both input and CorrelatedNL join that requires rewindable for
right input. I guess join SMALL->BIG has better performance without dependency
of rewindable.
Needs to investigation when we can force join order (e.g. by hint)
##########
File path:
modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/PlannerTest.java
##########
@@ -2617,19 +2643,138 @@ public void testJoinPushExpressionRule() throws
Exception {
RelTraitSet desired = rel.getCluster().traitSet()
.replace(IgniteConvention.INSTANCE)
.replace(IgniteDistributions.single())
+ .replace(CorrelationTrait.UNCORRELATED)
.simplify();
RelNode phys = planner.transform(PlannerPhase.OPTIMIZATION,
desired, rel);
assertNotNull(phys);
- assertEquals("" +
- "IgniteCorrelatedNestedLoopJoin(condition=[=(CAST(+($0,
$1)):INTEGER, 2)], joinType=[inner])\n" +
- " IgniteTableScan(table=[[PUBLIC, DEPT]],
requiredColunms=[{0}])\n" +
- " IgniteTableScan(table=[[PUBLIC, EMP]],
filters=[=(CAST(+($cor3.DEPTNO, $t0)):INTEGER, 2)], requiredColunms=[{2}])\n",
+ assertEquals(
+ "Invalid plan:\n" + RelOptUtil.toString(phys),
+ "IgniteCorrelatedNestedLoopJoin(condition=[=(CAST(+($0,
$1)):INTEGER, 2)], joinType=[inner])\n" +
+ " IgniteTableScan(table=[[PUBLIC, DEPT]],
requiredColumns=[{0}])\n" +
+ " IgniteTableScan(table=[[PUBLIC, EMP]],
filters=[=(CAST(+($cor3.DEPTNO, $t0)):INTEGER, 2)], requiredColumns=[{2}])\n",
RelOptUtil.toString(phys));
}
}
+ /**
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testTableSpoolTest() throws Exception {
+ IgniteTypeFactory f = new IgniteTypeFactory(IgniteTypeSystem.INSTANCE);
+
+ TestTable t0 = new TestTable(
+ new RelDataTypeFactory.Builder(f)
+ .add("ID", f.createJavaType(Integer.class))
+ .add("JID", f.createJavaType(Integer.class))
+ .add("VAL", f.createJavaType(String.class))
+ .build()) {
+
+ @Override public IgniteDistribution distribution() {
+ return IgniteDistributions.affinity(0, "T0", "hash");
+ }
+ };
+
+ TestTable t1 = new TestTable(
+ new RelDataTypeFactory.Builder(f)
+ .add("ID", f.createJavaType(Integer.class))
+ .add("JID", f.createJavaType(Integer.class))
+ .add("VAL", f.createJavaType(String.class))
+ .build()) {
+
+ @Override public IgniteDistribution distribution() {
+ return IgniteDistributions.affinity(0, "T1", "hash");
+ }
+ };
+
+ IgniteSchema publicSchema = new IgniteSchema("PUBLIC");
+
+ publicSchema.addTable("T0", t0);
+ publicSchema.addTable("T1", t1);
+
+ SchemaPlus schema = createRootSchema(false)
+ .add("PUBLIC", publicSchema);
+
+ String sql = "select * " +
+ "from t0 " +
+ "join t1 on t0.jid = t1.jid ";
+
+ RelTraitDef<?>[] traitDefs = {
+ DistributionTraitDef.INSTANCE,
+ ConventionTraitDef.INSTANCE,
+ RelCollationTraitDef.INSTANCE,
+ RewindabilityTraitDef.INSTANCE,
+ CorrelationTraitDef.INSTANCE
+ };
+
+ PlanningContext ctx = PlanningContext.builder()
+ .localNodeId(F.first(nodes))
+ .originatingNodeId(F.first(nodes))
+ .parentContext(Contexts.empty())
+ .frameworkConfig(newConfigBuilder(FRAMEWORK_CONFIG)
+ .defaultSchema(schema)
+ .traitDefs(traitDefs)
+ .build())
+ .logger(log)
+ .query(sql)
+ .topologyVersion(AffinityTopologyVersion.NONE)
+ .build();
+
+ RelRoot relRoot;
+
+ try (IgnitePlanner planner = ctx.planner()) {
+ assertNotNull(planner);
+
+ String qry = ctx.query();
+
+ assertNotNull(qry);
+
+ // Parse
+ SqlNode sqlNode = planner.parse(qry);
+
+ // Validate
+ sqlNode = planner.validate(sqlNode);
+
+ // Convert to Relational operators graph
+ relRoot = planner.rel(sqlNode);
+
+ RelNode rel = relRoot.rel;
+
+ assertNotNull(rel);
+
+ // Transformation chain
+ RelTraitSet desired = rel.getCluster().traitSet()
+ .replace(IgniteConvention.INSTANCE)
+ .replace(IgniteDistributions.single())
+ .simplify();
+
+
planner.setDisabledRules(ImmutableSet.of("NestedLoopJoinConverter(in:NONE,out:IGNITE)"));
Review comment:
Now we have only two join implementation: NL join that doesn't require
rewindable for both input and CorrelatedNL join that requires rewindable for
right input. I guess join SMALL->BIG has better performance without dependency
of rewindable.
Needs to investigation when we can force join order (e.g. by hint)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]