use of org.apache.ignite.internal.sql.engine.schema.IgniteSchema in project ignite-3 by apache.
the class MergeJoinPlannerTest method testInnerPassThroughOrderByLeft11.
/**
* Test verifies the collation propagation from a parent node.
*
* <p>In case of inner join, collation that is superset of join keys, but its prefix contains columns outside of join keys, can't be
* propagated.
*
* @throws Exception In case of any unexpected error.
*/
@Test
public void testInnerPassThroughOrderByLeft11() 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 " + " join RIGHT_T " + " on LEFT_T.c1 = RIGHT_T.c1 " + " and LEFT_T.c2 = RIGHT_T.c2 " + " order by LEFT_T.c3, LEFT_T.c2, LEFT_T.c1";
IgniteRel rel = physicalPlan(sql, schema, DISABLED_RULES);
IgniteSort topSortNode = sortOnTopOfJoin(rel);
assertEquals(RelCollations.of(new RelFieldCollation(2, ASCENDING, RelFieldCollation.NullDirection.FIRST), new RelFieldCollation(1, ASCENDING, RelFieldCollation.NullDirection.FIRST), new RelFieldCollation(0, ASCENDING, RelFieldCollation.NullDirection.FIRST)), topSortNode.collation());
List<IgniteSort> sortNodes = sortOnTopOfScan(rel);
assertEquals(RelCollations.of(new RelFieldCollation(0, ASCENDING), new RelFieldCollation(1, ASCENDING)), sortNodes.get(0).collation());
assertEquals(RelCollations.of(new RelFieldCollation(0, ASCENDING), new RelFieldCollation(1, ASCENDING)), sortNodes.get(1).collation());
}
use of org.apache.ignite.internal.sql.engine.schema.IgniteSchema in project ignite-3 by apache.
the class MergeJoinPlannerTest method testInnerDeriveMixed1.
/**
* Test verifies the collation propagation from a parent node.
*
* <p>In case of inner join, left collation should be preferred if it fully covers join keys.
*
* @throws Exception In case of any unexpected error.
*/
@Test
public void testInnerDeriveMixed1() 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), new RelFieldCollation(1, ASCENDING)), "idx");
TestTable right = createTable("RIGHT_T", IgniteDistributions.single(), "C1", Integer.class, "C2", Integer.class, "C3", Integer.class);
right.addIndex(RelCollations.of(new RelFieldCollation(1, ASCENDING), new RelFieldCollation(0, ASCENDING)), "idx");
IgniteSchema schema = createSchema(left, 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, "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.schema.IgniteSchema in project ignite-3 by apache.
the class MergeJoinPlannerTest method testRightPassThroughOrderByLeft1.
/**
* Test verifies the collation propagation from a parent node.
*
* <p>In case of right join, collation consisted of left keys can't be propagated.
*
* @throws Exception In case of any unexpected error.
*/
@Test
public void testRightPassThroughOrderByLeft1() 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 " + " right join RIGHT_T " + " on LEFT_T.c1 = RIGHT_T.c1 " + " and LEFT_T.c2 = RIGHT_T.c2 " + " order by LEFT_T.c1, LEFT_T.c2";
IgniteRel rel = physicalPlan(sql, schema, DISABLED_RULES);
IgniteSort topSortNode = sortOnTopOfJoin(rel);
assertEquals(RelCollations.of(new RelFieldCollation(0, ASCENDING, RelFieldCollation.NullDirection.FIRST), new RelFieldCollation(1, ASCENDING, RelFieldCollation.NullDirection.FIRST)), topSortNode.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.schema.IgniteSchema in project ignite-3 by apache.
the class MergeJoinPlannerTest method testRightPassThroughOrderByRight3.
/**
* Test verifies the collation propagation from a parent node.
*
* <p>In case of right join, collation consisted of join keys only should be propagated as is.
*
* @throws Exception In case of any unexpected error.
*/
@Test
public void testRightPassThroughOrderByRight3() 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 " + " right join RIGHT_T " + " on LEFT_T.c1 = RIGHT_T.c1 " + " and LEFT_T.c2 = RIGHT_T.c2 " + " order by RIGHT_T.c1 DESC, RIGHT_T.c2 ASC";
IgniteRel rel = physicalPlan(sql, schema, DISABLED_RULES);
assertNull(sortOnTopOfJoin(rel));
List<IgniteSort> sortNodes = sortOnTopOfScan(rel);
RelCollation expected = RelCollations.of(new RelFieldCollation(0, DESCENDING, RelFieldCollation.NullDirection.LAST), new RelFieldCollation(1, ASCENDING, RelFieldCollation.NullDirection.FIRST));
assertEquals(expected, sortNodes.get(0).collation());
assertEquals(expected, sortNodes.get(1).collation());
}
use of org.apache.ignite.internal.sql.engine.schema.IgniteSchema in project ignite-3 by apache.
the class AggregateDistinctPlannerTest method mapReduceDistinctWithIndex.
/**
* MapReduceDistinctWithIndex.
* TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
*
* @throws Exception If failed.
*/
@ParameterizedTest
@EnumSource
public void mapReduceDistinctWithIndex(AggregateAlgorithm algo) throws Exception {
TestTable tbl = createAffinityTable().addIndex(RelCollations.of(ImmutableIntList.of(1, 2)), "val0_val1");
IgniteSchema publicSchema = new IgniteSchema("PUBLIC");
publicSchema.addTable("TEST", tbl);
String sql = "SELECT DISTINCT val0, val1 FROM test";
IgniteRel phys = physicalPlan(sql, publicSchema, algo.rulesToDisable);
IgniteAggregate mapAgg = findFirstNode(phys, byClass(algo.map));
IgniteReduceAggregateBase rdcAgg = findFirstNode(phys, byClass(algo.reduce));
assertNotNull(rdcAgg, "Invalid plan\n" + RelOptUtil.toString(phys, SqlExplainLevel.ALL_ATTRIBUTES));
assertNotNull(mapAgg, "Invalid plan\n" + RelOptUtil.toString(phys));
assertTrue(nullOrEmpty(rdcAgg.getAggregateCalls()), "Invalid plan\n" + RelOptUtil.toString(phys));
assertTrue(nullOrEmpty(mapAgg.getAggCallList()), "Invalid plan\n" + RelOptUtil.toString(phys));
if (algo == AggregateAlgorithm.SORT) {
assertNotNull(findFirstNode(phys, byClass(IgniteIndexScan.class)));
}
}
Aggregations