Search in sources :

Example 1 with IgniteIndexScan

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);
}
Also used : IgniteIndexScan(org.apache.ignite.internal.sql.engine.rel.IgniteIndexScan) IgniteTypeFactory(org.apache.ignite.internal.sql.engine.type.IgniteTypeFactory) IgniteRel(org.apache.ignite.internal.sql.engine.rel.IgniteRel) IgniteDistribution(org.apache.ignite.internal.sql.engine.trait.IgniteDistribution) RelDataTypeFactory(org.apache.calcite.rel.type.RelDataTypeFactory) IgniteSchema(org.apache.ignite.internal.sql.engine.schema.IgniteSchema) RexFieldAccess(org.apache.calcite.rex.RexFieldAccess) RexNode(org.apache.calcite.rex.RexNode) Test(org.junit.jupiter.api.Test)

Aggregations

RelDataTypeFactory (org.apache.calcite.rel.type.RelDataTypeFactory)1 RexFieldAccess (org.apache.calcite.rex.RexFieldAccess)1 RexNode (org.apache.calcite.rex.RexNode)1 IgniteIndexScan (org.apache.ignite.internal.sql.engine.rel.IgniteIndexScan)1 IgniteRel (org.apache.ignite.internal.sql.engine.rel.IgniteRel)1 IgniteSchema (org.apache.ignite.internal.sql.engine.schema.IgniteSchema)1 IgniteDistribution (org.apache.ignite.internal.sql.engine.trait.IgniteDistribution)1 IgniteTypeFactory (org.apache.ignite.internal.sql.engine.type.IgniteTypeFactory)1 Test (org.junit.jupiter.api.Test)1