use of org.apache.ignite.internal.sql.engine.rel.IgniteRel in project ignite-3 by apache.
the class MergeJoinPlannerTest method testInnerDerivePreserveLeft5.
/**
* Test verifies the collation propagation from a parent node.
*
* <p>In case of inner join, left collation that is superset or equal to join keys could be derived as is.
*
* @throws Exception In case of any unexpected error.
*/
@Test
public void testInnerDerivePreserveLeft5() throws Exception {
TestTable left = createTable("LEFT_T", IgniteDistributions.single(), "C1", Integer.class, "C2", Integer.class, "C3", Integer.class);
left.addIndex(RelCollations.of(new RelFieldCollation(0, ASCENDING, RelFieldCollation.NullDirection.FIRST), new RelFieldCollation(1, ASCENDING)), "idx");
IgniteSchema schema = createSchema(left, createTable("RIGHT_T", IgniteDistributions.single(), "C1", Integer.class, "C2", Integer.class, "C3", Integer.class));
String sql = "" + "select * " + " from LEFT_T " + " join RIGHT_T " + " on LEFT_T.c1 = RIGHT_T.c1 " + " and LEFT_T.c2 = RIGHT_T.c2 ";
IgniteRel rel = physicalPlan(sql, schema, DISABLED_RULES);
assertNull(sortOnTopOfScan(rel, "LEFT_T"));
assertEquals(RelCollations.of(new RelFieldCollation(0, ASCENDING, RelFieldCollation.NullDirection.FIRST), new RelFieldCollation(1, ASCENDING)), sortOnTopOfScan(rel, "RIGHT_T").collation());
}
use of org.apache.ignite.internal.sql.engine.rel.IgniteRel in project ignite-3 by apache.
the class MergeJoinPlannerTest method testInnerDerivePreserveLeft4.
/**
* Test verifies the collation propagation from a parent node.
*
* <p>In case of inner join, left collation that is superset or equal to join keys could be derived as is.
*
* @throws Exception In case of any unexpected error.
*/
@Test
public void testInnerDerivePreserveLeft4() throws Exception {
TestTable left = createTable("LEFT_T", IgniteDistributions.single(), "C1", Integer.class, "C2", Integer.class, "C3", Integer.class);
left.addIndex(RelCollations.of(new RelFieldCollation(0, ASCENDING, RelFieldCollation.NullDirection.LAST), new RelFieldCollation(1, ASCENDING, RelFieldCollation.NullDirection.LAST)), "idx");
IgniteSchema schema = createSchema(left, createTable("RIGHT_T", IgniteDistributions.single(), "C1", Integer.class, "C2", Integer.class, "C3", Integer.class));
String sql = "" + "select * " + " from LEFT_T " + " join RIGHT_T " + " on LEFT_T.c1 = RIGHT_T.c1 " + " and LEFT_T.c2 = RIGHT_T.c2 ";
IgniteRel rel = physicalPlan(sql, schema, DISABLED_RULES);
assertNull(sortOnTopOfScan(rel, "LEFT_T"));
assertEquals(RelCollations.of(new RelFieldCollation(0, ASCENDING), new RelFieldCollation(1, ASCENDING)), sortOnTopOfScan(rel, "RIGHT_T").collation());
}
use of org.apache.ignite.internal.sql.engine.rel.IgniteRel in project ignite-3 by apache.
the class MergeJoinPlannerTest method testFullPassThroughOrderByRight1.
/**
* Test verifies the collation propagation from a parent node.
*
* <p>In case of full join, any collation can't be propagated.
*
* @throws Exception In case of any unexpected error.
*/
@Test
public void testFullPassThroughOrderByRight1() throws Exception {
IgniteSchema schema = createSchema(createTable("LEFT_T", IgniteDistributions.single(), "C1", Integer.class, "C2", Integer.class, "C3", Integer.class), createTable("RIGHT_T", IgniteDistributions.single(), "C1", Integer.class, "C2", Integer.class, "C3", Integer.class));
String sql = "" + "select * " + " from LEFT_T " + " full join RIGHT_T " + " on LEFT_T.c1 = RIGHT_T.c1 " + " and LEFT_T.c2 = RIGHT_T.c2 " + " order by RIGHT_T.c1, RIGHT_T.c2";
IgniteRel rel = physicalPlan(sql, schema, DISABLED_RULES);
assertEquals(RelCollations.of(new RelFieldCollation(3, ASCENDING, RelFieldCollation.NullDirection.FIRST), new RelFieldCollation(4, ASCENDING, RelFieldCollation.NullDirection.FIRST)), sortOnTopOfJoin(rel).collation());
List<IgniteSort> sortNodes = sortOnTopOfScan(rel);
RelCollation expected = RelCollations.of(new RelFieldCollation(0, ASCENDING), new RelFieldCollation(1, ASCENDING));
assertEquals(expected, sortNodes.get(0).collation());
assertEquals(expected, sortNodes.get(1).collation());
}
use of org.apache.ignite.internal.sql.engine.rel.IgniteRel in project ignite-3 by apache.
the class MergeJoinPlannerTest method testInnerDerivePreserveLeft9.
/**
* Test verifies the collation propagation from a parent node.
*
* <p>In case of inner join, left collation that is superset or equal, but its prefix contains columns outside of join keys, can't be
* derived.
*
* @throws Exception In case of any unexpected error.
*/
@Test
public void testInnerDerivePreserveLeft9() throws Exception {
TestTable left = createTable("LEFT_T", IgniteDistributions.single(), "C1", Integer.class, "C2", Integer.class, "C3", Integer.class);
left.addIndex(RelCollations.of(new RelFieldCollation(2, ASCENDING), new RelFieldCollation(0, ASCENDING), new RelFieldCollation(1, ASCENDING)), "idx");
IgniteSchema schema = createSchema(left, createTable("RIGHT_T", IgniteDistributions.single(), "C1", Integer.class, "C2", Integer.class, "C3", Integer.class));
String sql = "" + "select * " + " from LEFT_T " + " join RIGHT_T " + " on LEFT_T.c1 = RIGHT_T.c1 " + " and LEFT_T.c2 = RIGHT_T.c2 ";
IgniteRel rel = physicalPlan(sql, schema, DISABLED_RULES);
assertEquals(RelCollations.of(new RelFieldCollation(0, ASCENDING), new RelFieldCollation(1, ASCENDING)), sortOnTopOfScan(rel, "LEFT_T").collation());
assertEquals(RelCollations.of(new RelFieldCollation(0, ASCENDING), new RelFieldCollation(1, ASCENDING)), sortOnTopOfScan(rel, "RIGHT_T").collation());
}
use of org.apache.ignite.internal.sql.engine.rel.IgniteRel in project ignite-3 by apache.
the class MergeJoinPlannerTest method testInnerDerivePreserveRight5.
/**
* Test verifies the collation propagation from a parent node.
*
* <p>In case of inner join, right collation that consists of join keys only could be derived as is.
*
* @throws Exception In case of any unexpected error.
*/
@Test
public void testInnerDerivePreserveRight5() throws Exception {
TestTable right = createTable("RIGHT_T", IgniteDistributions.single(), "C1", Integer.class, "C2", Integer.class, "C3", Integer.class);
right.addIndex(RelCollations.of(new RelFieldCollation(0, ASCENDING, RelFieldCollation.NullDirection.FIRST), new RelFieldCollation(1, ASCENDING, RelFieldCollation.NullDirection.FIRST)), "idx");
IgniteSchema schema = createSchema(createTable("LEFT_T", IgniteDistributions.single(), "C1", Integer.class, "C2", Integer.class, "C3", Integer.class), right);
String sql = "" + "select * " + " from LEFT_T " + " join RIGHT_T " + " on LEFT_T.c1 = RIGHT_T.c1 " + " and LEFT_T.c2 = RIGHT_T.c2 ";
IgniteRel rel = physicalPlan(sql, schema, DISABLED_RULES);
assertNull(sortOnTopOfScan(rel, "RIGHT_T"));
assertEquals(RelCollations.of(new RelFieldCollation(0, ASCENDING, RelFieldCollation.NullDirection.FIRST), new RelFieldCollation(1, ASCENDING, RelFieldCollation.NullDirection.FIRST)), sortOnTopOfScan(rel, "LEFT_T").collation());
}
Aggregations