use of org.apache.ignite.internal.sql.engine.schema.IgniteSchema in project ignite-3 by apache.
the class PlannerTest method testSplitterColocatedPartitionedPartitioned.
@Test
public void testSplitterColocatedPartitionedPartitioned() throws Exception {
IgniteTypeFactory f = new IgniteTypeFactory(IgniteTypeSystem.INSTANCE);
TestTable developer = new TestTable(new RelDataTypeFactory.Builder(f).add("ID", f.createJavaType(Integer.class)).add("NAME", f.createJavaType(String.class)).add("PROJECTID", f.createJavaType(Integer.class)).build()) {
@Override
public IgniteIndex getIndex(String idxName) {
return new IgniteIndex(null, null, null);
}
@Override
public ColocationGroup colocationGroup(MappingQueryContext ctx) {
return ColocationGroup.forAssignments(Arrays.asList(select(NODES, 0, 1), select(NODES, 1, 2), select(NODES, 2, 0), select(NODES, 0, 1), select(NODES, 1, 2)));
}
@Override
public IgniteDistribution distribution() {
return IgniteDistributions.affinity(0, "Developer", "hash");
}
};
TestTable project = new TestTable(new RelDataTypeFactory.Builder(f).add("ID", f.createJavaType(Integer.class)).add("NAME", f.createJavaType(String.class)).add("VER", f.createJavaType(Integer.class)).build()) {
@Override
public ColocationGroup colocationGroup(MappingQueryContext ctx) {
return ColocationGroup.forAssignments(Arrays.asList(select(NODES, 0, 1), select(NODES, 1, 2), select(NODES, 2, 0), select(NODES, 0, 1), select(NODES, 1, 2)));
}
@Override
public IgniteDistribution distribution() {
return IgniteDistributions.affinity(0, "Project", "hash");
}
};
IgniteSchema publicSchema = new IgniteSchema("PUBLIC");
publicSchema.addTable("DEVELOPER", developer);
publicSchema.addTable("PROJECT", project);
SchemaPlus schema = createRootSchema(false).add("PUBLIC", publicSchema);
String sql = "SELECT d.id, d.name, d.projectId, p.id0, p.ver0 " + "FROM PUBLIC.Developer d JOIN (" + "SELECT pp.id as id0, pp.ver as ver0 FROM PUBLIC.Project pp" + ") p " + "ON d.id = p.id0";
PlanningContext ctx = PlanningContext.builder().parentContext(BaseQueryContext.builder().logger(log).frameworkConfig(newConfigBuilder(FRAMEWORK_CONFIG).defaultSchema(schema).build()).build()).query(sql).parameters(2).build();
assertNotNull(ctx);
IgniteRel phys = physicalPlan(sql, ctx);
assertNotNull(phys);
MultiStepPlan plan = new MultiStepQueryPlan(new QueryTemplate(new Splitter().go(phys)), null);
assertNotNull(plan);
plan.init(this::intermediateMapping, mapContext(CollectionUtils.first(NODES), 0L));
assertNotNull(plan);
assertEquals(2, plan.fragments().size());
}
use of org.apache.ignite.internal.sql.engine.schema.IgniteSchema in project ignite-3 by apache.
the class ProjectFilterScanMergePlannerTest method setup.
/**
* {@inheritDoc}
*/
@BeforeAll
public void setup() {
publicSchema = new IgniteSchema("PUBLIC");
IgniteTypeFactory f = new IgniteTypeFactory(IgniteTypeSystem.INSTANCE);
RelDataType type = new RelDataTypeFactory.Builder(f).add("A", f.createSqlType(SqlTypeName.INTEGER)).add("B", f.createSqlType(SqlTypeName.INTEGER)).add("C", f.createSqlType(SqlTypeName.INTEGER)).build();
createTable(publicSchema, "TBL", type, IgniteDistributions.single());
}
use of org.apache.ignite.internal.sql.engine.schema.IgniteSchema in project ignite-3 by apache.
the class SetOpPlannerTest method setup.
/**
* Setup.
* TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
*/
@BeforeAll
public void setup() {
publicSchema = new IgniteSchema("PUBLIC");
IgniteTypeFactory f = new IgniteTypeFactory(IgniteTypeSystem.INSTANCE);
RelDataType type = new RelDataTypeFactory.Builder(f).add("ID", f.createJavaType(Integer.class)).add("NAME", f.createJavaType(String.class)).add("SALARY", f.createJavaType(Double.class)).build();
createTable(publicSchema, "RANDOM_TBL1", type, IgniteDistributions.random());
createTable(publicSchema, "RANDOM_TBL2", type, IgniteDistributions.random());
createTable(publicSchema, "BROADCAST_TBL1", type, IgniteDistributions.broadcast());
createTable(publicSchema, "BROADCAST_TBL2", type, IgniteDistributions.broadcast());
createTable(publicSchema, "SINGLE_TBL1", type, IgniteDistributions.single());
createTable(publicSchema, "SINGLE_TBL2", type, IgniteDistributions.single());
createTable(publicSchema, "AFFINITY_TBL1", type, IgniteDistributions.affinity(0, "Test1", "hash"));
createTable(publicSchema, "AFFINITY_TBL2", type, IgniteDistributions.affinity(0, "Test2", "hash"));
}
use of org.apache.ignite.internal.sql.engine.schema.IgniteSchema in project ignite-3 by apache.
the class SortAggregatePlannerTest method collationPermuteSingle.
/**
* CollationPermuteSingle.
* TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
*
* @throws Exception If failed.
*/
@Test
public void collationPermuteSingle() throws Exception {
IgniteTypeFactory f = new IgniteTypeFactory(IgniteTypeSystem.INSTANCE);
TestTable tbl = new TestTable(new RelDataTypeFactory.Builder(f).add("ID", f.createJavaType(Integer.class)).add("VAL0", f.createJavaType(Integer.class)).add("VAL1", f.createJavaType(Integer.class)).add("GRP0", f.createJavaType(Integer.class)).add("GRP1", f.createJavaType(Integer.class)).build()) {
@Override
public IgniteDistribution distribution() {
return IgniteDistributions.broadcast();
}
}.addIndex(RelCollations.of(ImmutableIntList.of(3, 4)), "grp0_1");
IgniteSchema publicSchema = new IgniteSchema("PUBLIC");
publicSchema.addTable("TEST", tbl);
String sql = "SELECT MIN(val0) FROM test GROUP BY grp1, grp0";
IgniteRel phys = physicalPlan(sql, publicSchema, "HashSingleAggregateConverterRule", "HashMapReduceAggregateConverterRule");
IgniteSingleSortAggregate agg = findFirstNode(phys, byClass(IgniteSingleSortAggregate.class));
assertNotNull(agg, "Invalid plan\n" + RelOptUtil.toString(phys));
assertNull(findFirstNode(phys, byClass(IgniteSort.class)), "Invalid plan\n" + RelOptUtil.toString(phys));
}
use of org.apache.ignite.internal.sql.engine.schema.IgniteSchema in project ignite-3 by apache.
the class JoinColocationPlannerTest method joinComplexToComplexAffWithDifferentOrder.
/**
* Re-hashing for complex affinity is not supported.
*/
@Test
public void joinComplexToComplexAffWithDifferentOrder() throws Exception {
TestTable complexTblDirect = createTable("COMPLEX_TBL_DIRECT", IgniteDistributions.affinity(ImmutableIntList.of(0, 1), ThreadLocalRandom.current().nextInt(), "hash"), "ID1", Integer.class, "ID2", Integer.class, "VAL", String.class);
complexTblDirect.addIndex(new IgniteIndex(RelCollations.of(ImmutableIntList.of(0, 1)), "PK", complexTblDirect));
TestTable complexTblIndirect = createTable("COMPLEX_TBL_INDIRECT", IgniteDistributions.affinity(ImmutableIntList.of(1, 0), ThreadLocalRandom.current().nextInt(), "hash"), "ID1", Integer.class, "ID2", Integer.class, "VAL", String.class);
complexTblIndirect.addIndex(new IgniteIndex(RelCollations.of(ImmutableIntList.of(0, 1)), "PK", complexTblIndirect));
IgniteSchema schema = createSchema(complexTblDirect, complexTblIndirect);
String sql = "select count(*) " + "from COMPLEX_TBL_DIRECT t1 " + "join COMPLEX_TBL_INDIRECT t2 on t1.id1 = t2.id1 and t1.id2 = t2.id2";
RelNode phys = physicalPlan(sql, schema, "NestedLoopJoinConverter", "CorrelatedNestedLoopJoin");
IgniteMergeJoin exchange = findFirstNode(phys, node -> node instanceof IgniteExchange && ((IgniteRel) node).distribution().function().affinity());
String invalidPlanMsg = "Invalid plan:\n" + RelOptUtil.toString(phys);
assertThat(invalidPlanMsg, exchange, nullValue());
}
Aggregations