use of io.crate.execution.ddl.tables.DropTableRequest in project crate by crate.
the class DropTablePlan method executeOrFail.
@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
TableInfo table = dropTable.table();
DropTableRequest request;
if (table == null) {
if (dropTable.maybeCorrupt()) {
// setting isPartitioned=true should be safe.
// It will delete a template if it exists, and if there is no template it shouldn't do any harm
request = new DropTableRequest(dropTable.tableName(), true);
} else {
// no-op, table is already gone
assert dropTable.dropIfExists() : "If table is null, IF EXISTS flag must have been present";
consumer.accept(InMemoryBatchIterator.of(ROW_ZERO, SENTINEL), null);
return;
}
} else {
boolean isPartitioned = table instanceof DocTableInfo && ((DocTableInfo) table).isPartitioned();
request = new DropTableRequest(table.ident(), isPartitioned);
}
dependencies.transportDropTableAction().execute(request, new ActionListener<>() {
@Override
public void onResponse(AcknowledgedResponse response) {
if (!response.isAcknowledged() && LOGGER.isWarnEnabled()) {
if (LOGGER.isWarnEnabled()) {
LOGGER.warn("Dropping table {} was not acknowledged. This could lead to inconsistent state.", dropTable.tableName());
}
}
consumer.accept(InMemoryBatchIterator.of(ROW_ONE, SENTINEL), null);
}
@Override
public void onFailure(Exception e) {
if (dropTable.dropIfExists() && e instanceof IndexNotFoundException) {
consumer.accept(InMemoryBatchIterator.of(ROW_ZERO, SENTINEL), null);
} else {
consumer.accept(null, e);
}
}
});
}
Aggregations