use of io.crate.execution.ddl.views.CreateViewRequest in project crate by crate.
the class CreateViewPlan method executeOrFail.
@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
User owner = createViewStmt.owner();
String formattedQuery = SqlFormatter.formatSql(createViewStmt.query(), makeExpressions(params));
ensureFormattedQueryCanStillBeAnalyzed(createViewStmt.name(), dependencies.nodeContext(), dependencies.schemas(), plannerContext.transactionContext(), formattedQuery, createViewStmt.replaceExisting());
CreateViewRequest request = new CreateViewRequest(createViewStmt.name(), formattedQuery, createViewStmt.replaceExisting(), owner == null ? null : owner.name());
dependencies.createViewAction().execute(request, new OneRowActionListener<>(consumer, resp -> {
if (resp.alreadyExistsFailure()) {
throw new RelationAlreadyExists(createViewStmt.name());
}
return new Row1(1L);
}));
}
Aggregations