use of io.crate.exceptions.RelationsUnknown in project crate by crate.
the class ViewAnalyzer method analyze.
public AnalyzedDropView analyze(DropView dropView, CoordinatorTxnCtx txnCtx) {
// No exists check to avoid stale clusterState race conditions
ArrayList<RelationName> views = new ArrayList<>(dropView.names().size());
ArrayList<RelationName> missing = new ArrayList<>();
for (QualifiedName qualifiedName : dropView.names()) {
try {
views.add(schemas.resolveView(qualifiedName, txnCtx.sessionContext().searchPath()).v2());
} catch (RelationUnknown e) {
if (!dropView.ifExists()) {
missing.add(RelationName.of(qualifiedName, txnCtx.sessionContext().searchPath().currentSchema()));
}
}
}
if (!missing.isEmpty()) {
throw new RelationsUnknown(missing);
}
return new AnalyzedDropView(views, dropView.ifExists());
}
use of io.crate.exceptions.RelationsUnknown in project crate by crate.
the class DropViewPlan method executeOrFail.
@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
DropViewRequest request = new DropViewRequest(dropView.views(), dropView.ifExists());
Function<DropViewResponse, Row> responseToRow = resp -> {
if (dropView.ifExists() || resp.missing().isEmpty()) {
return new Row1((long) dropView.views().size() - resp.missing().size());
}
throw new RelationsUnknown(resp.missing());
};
dependencies.dropViewAction().execute(request, new OneRowActionListener<>(consumer, responseToRow));
}
Aggregations