use of org.apache.ignite.internal.sql.engine.rel.IgniteIndexScan in project ignite-3 by apache.
the class CorrelatedNestedLoopJoinPlannerTest method testValidIndexExpressions.
/**
* Check equi-join. CorrelatedNestedLoopJoinTest is applicable for it.
*/
@Test
public void testValidIndexExpressions() throws Exception {
IgniteSchema publicSchema = new IgniteSchema("PUBLIC");
IgniteTypeFactory f = new IgniteTypeFactory(IgniteTypeSystem.INSTANCE);
publicSchema.addTable("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.broadcast();
}
});
publicSchema.addTable("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.broadcast();
}
}.addIndex(RelCollations.of(ImmutableIntList.of(1, 0)), "t1_jid_idx"));
String sql = "select * " + "from t0 " + "join t1 on t0.jid = t1.jid";
IgniteRel phys = physicalPlan(sql, publicSchema, "MergeJoinConverter", "NestedLoopJoinConverter");
System.out.println("+++ " + RelOptUtil.toString(phys));
assertNotNull(phys);
IgniteIndexScan idxScan = findFirstNode(phys, byClass(IgniteIndexScan.class));
List<RexNode> lowerBound = idxScan.lowerBound();
assertNotNull(lowerBound, "Invalid plan\n" + RelOptUtil.toString(phys));
assertEquals(3, lowerBound.size());
assertTrue(((RexLiteral) lowerBound.get(0)).isNull());
assertTrue(((RexLiteral) lowerBound.get(2)).isNull());
assertTrue(lowerBound.get(1) instanceof RexFieldAccess);
List<RexNode> upperBound = idxScan.upperBound();
assertNotNull(upperBound, "Invalid plan\n" + RelOptUtil.toString(phys));
assertEquals(3, upperBound.size());
assertTrue(((RexLiteral) upperBound.get(0)).isNull());
assertTrue(((RexLiteral) upperBound.get(2)).isNull());
assertTrue(upperBound.get(1) instanceof RexFieldAccess);
}
Aggregations