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());
}
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());
}
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());
}
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());
}
Aggregations