use of herddb.model.planner.DeleteOp in project herddb by diennea.
the class CalcitePlanner method planDelete.
private PlannerOp planDelete(EnumerableTableModify dml) {
PlannerOp input = convertRelNode(dml.getInput(), null, false);
final String tableSpace = dml.getTable().getQualifiedName().get(0);
final String tableName = dml.getTable().getQualifiedName().get(1);
final TableImpl tableImpl = (TableImpl) dml.getTable().unwrap(org.apache.calcite.schema.Table.class);
Table table = tableImpl.tableManager.getTable();
DeleteStatement delete = null;
if (input instanceof TableScanOp) {
delete = new DeleteStatement(tableSpace, tableName, null, null);
} else if (input instanceof FilterOp) {
FilterOp filter = (FilterOp) input;
if (filter.getInput() instanceof TableScanOp) {
SQLRecordPredicate pred = new SQLRecordPredicate(table, null, filter.getCondition());
delete = new DeleteStatement(tableSpace, tableName, null, pred);
}
} else if (input instanceof BindableTableScanOp) {
BindableTableScanOp filter = (BindableTableScanOp) input;
Predicate pred = filter.getStatement().getPredicate();
delete = new DeleteStatement(tableSpace, tableName, null, pred);
}
if (delete != null) {
return new SimpleDeleteOp(delete);
} else {
return new DeleteOp(tableSpace, tableName, input);
}
}
Aggregations