Search in sources :

Example 1 with IgniteTableModify

use of org.apache.ignite.internal.sql.engine.rel.IgniteTableModify in project ignite-3 by apache.

the class TableDmlPlannerTest method insertCachesIndexScan.

/**
 * InsertCachesIndexScan.
 * TODO Documentation https://issues.apache.org/jira/browse/IGNITE-15859
 *
 * @throws Exception If failed.
 */
@Test
public void insertCachesIndexScan() 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 = "insert into test select 2 * val from test";
    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 2 with IgniteTableModify

use of org.apache.ignite.internal.sql.engine.rel.IgniteTableModify in project ignite-3 by apache.

the class TableModifyConverterRule method convert.

/**
 * {@inheritDoc}
 */
@Override
protected PhysicalNode convert(RelOptPlanner planner, RelMetadataQuery mq, LogicalTableModify rel) {
    RelOptCluster cluster = rel.getCluster();
    RelTraitSet traits = cluster.traitSetOf(IgniteConvention.INSTANCE).replace(IgniteDistributions.single()).replace(RewindabilityTrait.ONE_WAY).replace(RelCollations.EMPTY);
    RelNode input = convert(rel.getInput(), traits);
    return new IgniteTableModify(cluster, traits, rel.getTable(), input, rel.getOperation(), rel.getUpdateColumnList(), rel.getSourceExpressionList(), rel.isFlattened());
}
Also used : RelOptCluster(org.apache.calcite.plan.RelOptCluster) RelNode(org.apache.calcite.rel.RelNode) IgniteTableModify(org.apache.ignite.internal.sql.engine.rel.IgniteTableModify) RelTraitSet(org.apache.calcite.plan.RelTraitSet)

Example 3 with IgniteTableModify

use of org.apache.ignite.internal.sql.engine.rel.IgniteTableModify 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 4 with IgniteTableModify

use of org.apache.ignite.internal.sql.engine.rel.IgniteTableModify 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)

Aggregations

RelNode (org.apache.calcite.rel.RelNode)4 IgniteTableModify (org.apache.ignite.internal.sql.engine.rel.IgniteTableModify)4 Spool (org.apache.calcite.rel.core.Spool)3 IgniteSchema (org.apache.ignite.internal.sql.engine.schema.IgniteSchema)3 Test (org.junit.jupiter.api.Test)3 IgniteIndex (org.apache.ignite.internal.sql.engine.schema.IgniteIndex)2 RelOptCluster (org.apache.calcite.plan.RelOptCluster)1 RelTraitSet (org.apache.calcite.plan.RelTraitSet)1