| 35 | import io.crate.planner.operators.SubQueryResults; |
| 36 | |
| 37 | public class DropViewPlan implements Plan { |
| 38 | |
| 39 | private final AnalyzedDropView dropView; |
| 40 | |
| 41 | DropViewPlan(AnalyzedDropView dropView) { |
| 42 | this.dropView = dropView; |
| 43 | } |
| 44 | |
| 45 | @Override |
| 46 | public StatementType type() { |
| 47 | return StatementType.DDL; |
| 48 | } |
| 49 | |
| 50 | @Override |
| 51 | public void executeOrFail(DependencyCarrier dependencies, |
| 52 | PlannerContext plannerContext, |
| 53 | RowConsumer consumer, |
| 54 | Row params, |
| 55 | SubQueryResults subQueryResults) { |
| 56 | DropViewRequest request = new DropViewRequest(dropView.views(), dropView.ifExists()); |
| 57 | Function<DropViewResponse, Row> responseToRow = resp -> { |
| 58 | if (dropView.ifExists() || resp.missing().isEmpty()) { |
| 59 | return new Row1((long) dropView.views().size() - resp.missing().size()); |
| 60 | } |
| 61 | throw new RelationsUnknown(resp.missing()); |
| 62 | }; |
| 63 | dependencies.client().execute(TransportDropView.ACTION, request) |
| 64 | .whenComplete(new OneRowActionListener<>(consumer, responseToRow)); |
| 65 | } |
| 66 | } |
nothing calls this directly
no outgoing calls
no test coverage detected