use of org.apache.ignite.internal.sql.engine.schema.IgniteSchema in project ignite-3 by apache.
the class UnionPlannerTest method prepareSchema.
/**
* Create schema for tests.
*
* @return Ignite schema.
*/
private IgniteSchema prepareSchema() {
IgniteTypeFactory f = new IgniteTypeFactory(IgniteTypeSystem.INSTANCE);
TestTable tbl1 = new TestTable(new RelDataTypeFactory.Builder(f).add("ID", f.createJavaType(Integer.class)).add("NAME", f.createJavaType(String.class)).add("SALARY", f.createJavaType(Double.class)).build()) {
@Override
public IgniteDistribution distribution() {
return IgniteDistributions.affinity(0, "Table1", "hash");
}
};
TestTable tbl2 = new TestTable(new RelDataTypeFactory.Builder(f).add("ID", f.createJavaType(Integer.class)).add("NAME", f.createJavaType(String.class)).add("SALARY", f.createJavaType(Double.class)).build()) {
@Override
public IgniteDistribution distribution() {
return IgniteDistributions.affinity(0, "Table2", "hash");
}
};
TestTable tbl3 = new TestTable(new RelDataTypeFactory.Builder(f).add("ID", f.createJavaType(Integer.class)).add("NAME", f.createJavaType(String.class)).add("SALARY", f.createJavaType(Double.class)).build()) {
@Override
public IgniteDistribution distribution() {
return IgniteDistributions.affinity(0, "Table3", "hash");
}
};
IgniteSchema publicSchema = new IgniteSchema("PUBLIC");
publicSchema.addTable("TABLE1", tbl1);
publicSchema.addTable("TABLE2", tbl2);
publicSchema.addTable("TABLE3", tbl3);
return publicSchema;
}
use of org.apache.ignite.internal.sql.engine.schema.IgniteSchema in project ignite-3 by apache.
the class MergeJoinPlannerTest method testInnerPassThroughOrderByLeft3.
/**
* Test verifies the collation propagation from a parent node.
*
* <p>In case of inner join, collation consisted of join keys of left table should be propagated as is.
*
* @throws Exception In case of any unexpected error.
*/
@Test
public void testInnerPassThroughOrderByLeft3() 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.c1 DESC, LEFT_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 MergeJoinPlannerTest method testInnerDerivePreserveRight8.
/**
* Test verifies the collation propagation from a parent node.
*
* <p>In case of inner join, right collation that is superset of join keys could be derived as is.
*
* @throws Exception In case of any unexpected error.
*/
@Test
public void testInnerDerivePreserveRight8() 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, DESCENDING, RelFieldCollation.NullDirection.LAST), new RelFieldCollation(1, ASCENDING, RelFieldCollation.NullDirection.FIRST), new RelFieldCollation(2, 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, DESCENDING, RelFieldCollation.NullDirection.LAST), new RelFieldCollation(1, ASCENDING, RelFieldCollation.NullDirection.FIRST)), sortOnTopOfScan(rel, "LEFT_T").collation());
}
use of org.apache.ignite.internal.sql.engine.schema.IgniteSchema in project ignite-3 by apache.
the class MergeJoinPlannerTest method testInnerPassThroughOrderByRight8.
/**
* Test verifies the collation propagation from a parent node.
*
* <p>In case of inner join, collation that is subset of join keys should be propagated as is.
*
* @throws Exception In case of any unexpected error.
*/
@Test
public void testInnerPassThroughOrderByRight8() 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 " + " and LEFT_T.c3 = RIGHT_T.c3 " + " order by RIGHT_T.c1 DESC, RIGHT_T.c2 DESC";
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, DESCENDING, RelFieldCollation.NullDirection.LAST), new RelFieldCollation(2, 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 testInnerPassThroughOrderByRight10.
/**
* Test verifies the collation propagation from a parent node.
*
* <p>In case of inner join, collation that is subset of join keys should be propagated as is.
*
* @throws Exception In case of any unexpected error.
*/
@Test
public void testInnerPassThroughOrderByRight10() 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 " + " and LEFT_T.c3 = RIGHT_T.c3 " + " order by RIGHT_T.c1 ASC NULLS LAST, RIGHT_T.c2 ASC NULLS LAST";
IgniteRel rel = physicalPlan(sql, schema, DISABLED_RULES);
assertNull(sortOnTopOfJoin(rel));
List<IgniteSort> sortNodes = sortOnTopOfScan(rel);
RelCollation expected = RelCollations.of(new RelFieldCollation(0, ASCENDING), new RelFieldCollation(1, ASCENDING), new RelFieldCollation(2, ASCENDING));
assertEquals(expected, sortNodes.get(0).collation());
assertEquals(expected, sortNodes.get(1).collation());
}
Aggregations