Search in sources :

Example 76 with IgniteSchema

use of org.apache.ignite.internal.sql.engine.schema.IgniteSchema in project ignite-3 by apache.

the class TableDmlPlannerTest method insertCachesTableScan.

/**
 * InsertCachesTableScan.
 * TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
 *
 * @throws Exception If failed.
 */
@Test
public void insertCachesTableScan() throws Exception {
    IgniteSchema schema = createSchema(createTable("TEST", IgniteDistributions.random(), "VAL", Integer.class));
    String sql = "insert into test select 2 * val from test";
    RelNode phys = physicalPlan(sql, schema, "LogicalIndexScanConverterRule");
    assertNotNull(phys);
    String invalidPlanMsg = "Invalid plan:\n" + RelOptUtil.toString(phys);
    IgniteTableModify modifyNode = findFirstNode(phys, byClass(IgniteTableModify.class));
    assertThat(invalidPlanMsg, modifyNode, notNullValue());
    assertThat(invalidPlanMsg, modifyNode.getInput(), instanceOf(Spool.class));
    Spool spool = (Spool) modifyNode.getInput();
    assertThat(invalidPlanMsg, spool.readType, equalTo(Spool.Type.EAGER));
    assertThat(invalidPlanMsg, findFirstNode(phys, byClass(IgniteTableScan.class)), notNullValue());
}
Also used : RelNode(org.apache.calcite.rel.RelNode) IgniteTableModify(org.apache.ignite.internal.sql.engine.rel.IgniteTableModify) Spool(org.apache.calcite.rel.core.Spool) IgniteSchema(org.apache.ignite.internal.sql.engine.schema.IgniteSchema) Test(org.junit.jupiter.api.Test)

Example 77 with IgniteSchema

use of org.apache.ignite.internal.sql.engine.schema.IgniteSchema in project ignite-3 by apache.

the class TableDmlPlannerTest method updateNotCachesNonDependentIndexScan.

/**
 * UpdateNotCachesNonDependentIndexScan.
 * TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
 *
 * @throws Exception If failed.
 */
@Test
public void updateNotCachesNonDependentIndexScan() throws Exception {
    TestTable tbl = createTable("TEST", IgniteDistributions.random(), "VAL", Integer.class, "IDX_VAL", Integer.class);
    tbl.addIndex(new IgniteIndex(RelCollations.of(1), "IDX", tbl));
    IgniteSchema schema = createSchema(tbl);
    String sql = "update test set val = 2 * val where idx_val between 2 and 10";
    RelNode phys = physicalPlan(sql, schema, "LogicalTableScanConverterRule");
    assertNotNull(phys);
    String invalidPlanMsg = "Invalid plan:\n" + RelOptUtil.toString(phys);
    assertThat(invalidPlanMsg, findFirstNode(phys, byClass(Spool.class)), nullValue());
    assertThat(invalidPlanMsg, findFirstNode(phys, byClass(IgniteIndexScan.class)), notNullValue());
}
Also used : IgniteIndex(org.apache.ignite.internal.sql.engine.schema.IgniteIndex) RelNode(org.apache.calcite.rel.RelNode) IgniteSchema(org.apache.ignite.internal.sql.engine.schema.IgniteSchema) Test(org.junit.jupiter.api.Test)

Example 78 with IgniteSchema

use of org.apache.ignite.internal.sql.engine.schema.IgniteSchema in project ignite-3 by apache.

the class TableDmlPlannerTest method updateNotCachesTableScan.

/**
 * UpdateNotCachesTableScan.
 * TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
 *
 * @throws Exception If failed.
 */
@Test
public void updateNotCachesTableScan() throws Exception {
    IgniteSchema schema = createSchema(createTable("TEST", IgniteDistributions.random(), "VAL", Integer.class));
    String sql = "update test set val = 2 * val";
    RelNode phys = physicalPlan(sql, schema, "LogicalIndexScanConverterRule");
    assertNotNull(phys);
    String invalidPlanMsg = "Invalid plan:\n" + RelOptUtil.toString(phys);
    assertThat(invalidPlanMsg, findFirstNode(phys, byClass(Spool.class)), nullValue());
    assertThat(invalidPlanMsg, findFirstNode(phys, byClass(IgniteTableScan.class)), notNullValue());
}
Also used : RelNode(org.apache.calcite.rel.RelNode) IgniteSchema(org.apache.ignite.internal.sql.engine.schema.IgniteSchema) Test(org.junit.jupiter.api.Test)

Example 79 with IgniteSchema

use of org.apache.ignite.internal.sql.engine.schema.IgniteSchema in project ignite-3 by apache.

the class TableDmlPlannerTest method updateCachesDependentIndexScan.

/**
 * UpdateCachesDependentIndexScan.
 * TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
 *
 * @throws Exception If failed.
 */
@Test
public void updateCachesDependentIndexScan() throws Exception {
    TestTable tbl = createTable("TEST", IgniteDistributions.random(), "VAL", Integer.class);
    tbl.addIndex(new IgniteIndex(RelCollations.of(0), "IDX", tbl));
    IgniteSchema schema = createSchema(tbl);
    String sql = "update test set val = 2 * val where val between 2 and 10";
    RelNode phys = physicalPlan(sql, schema, "LogicalTableScanConverterRule");
    assertNotNull(phys);
    String invalidPlanMsg = "Invalid plan:\n" + RelOptUtil.toString(phys);
    IgniteTableModify modifyNode = findFirstNode(phys, byClass(IgniteTableModify.class));
    assertThat(invalidPlanMsg, modifyNode, notNullValue());
    assertThat(invalidPlanMsg, modifyNode.getInput(), instanceOf(Spool.class));
    Spool spool = (Spool) modifyNode.getInput();
    assertThat(invalidPlanMsg, spool.readType, equalTo(Spool.Type.EAGER));
    assertThat(invalidPlanMsg, findFirstNode(phys, byClass(IgniteIndexScan.class)), notNullValue());
}
Also used : IgniteIndex(org.apache.ignite.internal.sql.engine.schema.IgniteIndex) RelNode(org.apache.calcite.rel.RelNode) IgniteTableModify(org.apache.ignite.internal.sql.engine.rel.IgniteTableModify) Spool(org.apache.calcite.rel.core.Spool) IgniteSchema(org.apache.ignite.internal.sql.engine.schema.IgniteSchema) Test(org.junit.jupiter.api.Test)

Example 80 with IgniteSchema

use of org.apache.ignite.internal.sql.engine.schema.IgniteSchema in project ignite-3 by apache.

the class TableFunctionPlannerTest 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_TBL", type, IgniteDistributions.random());
    createTable(publicSchema, "BROADCAST_TBL", type, IgniteDistributions.broadcast());
}
Also used : IgniteTypeFactory(org.apache.ignite.internal.sql.engine.type.IgniteTypeFactory) RelDataType(org.apache.calcite.rel.type.RelDataType) IgniteSchema(org.apache.ignite.internal.sql.engine.schema.IgniteSchema) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

IgniteSchema (org.apache.ignite.internal.sql.engine.schema.IgniteSchema)115 Test (org.junit.jupiter.api.Test)105 IgniteRel (org.apache.ignite.internal.sql.engine.rel.IgniteRel)93 RelFieldCollation (org.apache.calcite.rel.RelFieldCollation)66 IgniteSort (org.apache.ignite.internal.sql.engine.rel.IgniteSort)42 RelCollation (org.apache.calcite.rel.RelCollation)33 IgniteTypeFactory (org.apache.ignite.internal.sql.engine.type.IgniteTypeFactory)28 RelDataTypeFactory (org.apache.calcite.rel.type.RelDataTypeFactory)20 RelNode (org.apache.calcite.rel.RelNode)12 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)11 IgniteIndex (org.apache.ignite.internal.sql.engine.schema.IgniteIndex)9 IgniteDistribution (org.apache.ignite.internal.sql.engine.trait.IgniteDistribution)9 SchemaPlus (org.apache.calcite.schema.SchemaPlus)8 RexFieldAccess (org.apache.calcite.rex.RexFieldAccess)7 PlanningContext (org.apache.ignite.internal.sql.engine.prepare.PlanningContext)7 IgniteIndexScan (org.apache.ignite.internal.sql.engine.rel.IgniteIndexScan)7 RexNode (org.apache.calcite.rex.RexNode)6 MappingQueryContext (org.apache.ignite.internal.sql.engine.prepare.MappingQueryContext)6 MultiStepPlan (org.apache.ignite.internal.sql.engine.prepare.MultiStepPlan)6 MultiStepQueryPlan (org.apache.ignite.internal.sql.engine.prepare.MultiStepQueryPlan)6