Search in sources :

Example 1 with RelationNameSwap

use of io.crate.execution.ddl.RelationNameSwap in project crate by crate.

the class SwapTablePlan method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
    boolean dropSource = Objects.requireNonNull(DataTypes.BOOLEAN.sanitizeValue(SymbolEvaluator.evaluate(plannerContext.transactionContext(), dependencies.nodeContext(), swapTable.dropSource(), params, subQueryResults)), SwapTableAnalyzer.DROP_SOURCE + " option must be true or false, not null");
    RelationName source = swapTable.source().ident();
    SwapRelationsRequest request = new SwapRelationsRequest(Collections.singletonList(new RelationNameSwap(source, swapTable.target().ident())), dropSource ? Collections.singletonList(source) : emptyList());
    OneRowActionListener<AcknowledgedResponse> listener = new OneRowActionListener<>(consumer, r -> r.isAcknowledged() ? new Row1(1L) : new Row1(0L));
    dependencies.swapRelationsAction().execute(request, listener);
}
Also used : RelationNameSwap(io.crate.execution.ddl.RelationNameSwap) Row1(io.crate.data.Row1) OneRowActionListener(io.crate.execution.support.OneRowActionListener) SwapRelationsRequest(io.crate.execution.ddl.SwapRelationsRequest) AcknowledgedResponse(org.elasticsearch.action.support.master.AcknowledgedResponse) RelationName(io.crate.metadata.RelationName)

Aggregations

Row1 (io.crate.data.Row1)1 RelationNameSwap (io.crate.execution.ddl.RelationNameSwap)1 SwapRelationsRequest (io.crate.execution.ddl.SwapRelationsRequest)1 OneRowActionListener (io.crate.execution.support.OneRowActionListener)1 RelationName (io.crate.metadata.RelationName)1 AcknowledgedResponse (org.elasticsearch.action.support.master.AcknowledgedResponse)1