Search in sources :

Example 36 with RowConsumer

use of io.crate.data.RowConsumer in project crate by crate.

the class AlterTableAddColumnPlan method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) throws Exception {
    BoundAddColumn stmt = bind(alterTable, plannerContext.transactionContext(), dependencies.nodeContext(), params, subQueryResults, dependencies.fulltextAnalyzerResolver());
    dependencies.alterTableOperation().executeAlterTableAddColumn(stmt).whenComplete(new OneRowActionListener<>(consumer, rCount -> new Row1(rCount == null ? -1 : rCount)));
}
Also used : AnalyzedColumnDefinition(io.crate.analyze.AnalyzedColumnDefinition) HashMap(java.util.HashMap) ObjectType(io.crate.types.ObjectType) Function(java.util.function.Function) ArrayList(java.util.ArrayList) DependencyCarrier(io.crate.planner.DependencyCarrier) SymbolEvaluator(io.crate.analyze.SymbolEvaluator) Settings(org.elasticsearch.common.settings.Settings) Locale(java.util.Locale) Map(java.util.Map) OneRowActionListener(io.crate.execution.support.OneRowActionListener) AnalyzedAlterTableAddColumn(io.crate.analyze.AnalyzedAlterTableAddColumn) FulltextAnalyzerResolver(io.crate.metadata.FulltextAnalyzerResolver) LinkedHashSet(java.util.LinkedHashSet) DocSysColumns(io.crate.metadata.doc.DocSysColumns) DocTableInfo(io.crate.metadata.doc.DocTableInfo) TableInfo(io.crate.metadata.table.TableInfo) NodeContext(io.crate.metadata.NodeContext) BoundAddColumn(io.crate.analyze.BoundAddColumn) ColumnIdent(io.crate.metadata.ColumnIdent) Reference(io.crate.metadata.Reference) CheckConstraint(io.crate.sql.tree.CheckConstraint) RowConsumer(io.crate.data.RowConsumer) Objects(java.util.Objects) AnalyzedTableElements(io.crate.analyze.AnalyzedTableElements) List(java.util.List) Row(io.crate.data.Row) Symbol(io.crate.expression.symbol.Symbol) PlannerContext(io.crate.planner.PlannerContext) Plan(io.crate.planner.Plan) SubQueryResults(io.crate.planner.operators.SubQueryResults) VisibleForTesting(io.crate.common.annotations.VisibleForTesting) Comparator(java.util.Comparator) Row1(io.crate.data.Row1) CoordinatorTxnCtx(io.crate.metadata.CoordinatorTxnCtx) Row1(io.crate.data.Row1) BoundAddColumn(io.crate.analyze.BoundAddColumn)

Example 37 with RowConsumer

use of io.crate.data.RowConsumer in project crate by crate.

the class ExplainPlannerTest method testExplainAnalyzeMultiPhasePlanNotSupported.

@Test
public void testExplainAnalyzeMultiPhasePlanNotSupported() {
    ExplainPlan plan = e.plan("EXPLAIN ANALYZE SELECT * FROM users WHERE name = (SELECT 'crate') or id = (SELECT 1)");
    PlannerContext plannerContext = e.getPlannerContext(clusterService.state());
    CountDownLatch counter = new CountDownLatch(1);
    AtomicReference<BatchIterator<Row>> itRef = new AtomicReference<>();
    AtomicReference<Throwable> failureRef = new AtomicReference<>();
    plan.execute(null, plannerContext, new RowConsumer() {

        @Override
        public void accept(BatchIterator<Row> iterator, @Nullable Throwable failure) {
            itRef.set(iterator);
            failureRef.set(failure);
            counter.countDown();
        }

        @Override
        public CompletableFuture<?> completionFuture() {
            return null;
        }
    }, Row.EMPTY, SubQueryResults.EMPTY);
    assertNull(itRef.get());
    assertNotNull(failureRef.get());
    assertThat(failureRef.get().getMessage(), containsString("EXPLAIN ANALYZE does not support profiling multi-phase plans, such as queries with scalar subselects."));
}
Also used : BatchIterator(io.crate.data.BatchIterator) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) CompletableFuture(java.util.concurrent.CompletableFuture) RowConsumer(io.crate.data.RowConsumer) Row(io.crate.data.Row) ExplainPlan(io.crate.planner.node.management.ExplainPlan) Test(org.junit.Test) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest)

Aggregations

RowConsumer (io.crate.data.RowConsumer)37 Row (io.crate.data.Row)26 Row1 (io.crate.data.Row1)24 SubQueryResults (io.crate.planner.operators.SubQueryResults)24 OneRowActionListener (io.crate.execution.support.OneRowActionListener)22 DependencyCarrier (io.crate.planner.DependencyCarrier)22 PlannerContext (io.crate.planner.PlannerContext)22 Plan (io.crate.planner.Plan)21 Symbol (io.crate.expression.symbol.Symbol)18 SymbolEvaluator (io.crate.analyze.SymbolEvaluator)17 Function (java.util.function.Function)17 VisibleForTesting (io.crate.common.annotations.VisibleForTesting)12 NodeContext (io.crate.metadata.NodeContext)11 List (java.util.List)10 CoordinatorTxnCtx (io.crate.metadata.CoordinatorTxnCtx)9 ArrayList (java.util.ArrayList)9 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)8 Test (org.junit.Test)8 DocTableInfo (io.crate.metadata.doc.DocTableInfo)7 Settings (org.elasticsearch.common.settings.Settings)7