Search in sources :

Example 1 with ConsumerContext

use of io.crate.planner.consumer.ConsumerContext in project crate by crate.

the class Planner method visitUpdateStatement.

@Override
protected Plan visitUpdateStatement(UpdateAnalyzedStatement statement, Context context) {
    ConsumerContext consumerContext = new ConsumerContext(context);
    Plan plan = updateConsumer.consume(statement, consumerContext);
    if (plan == null) {
        throw new IllegalArgumentException("Couldn't plan Update statement");
    }
    return plan;
}
Also used : ConsumerContext(io.crate.planner.consumer.ConsumerContext) GenericShowPlan(io.crate.planner.node.management.GenericShowPlan) SetSessionPlan(io.crate.planner.statement.SetSessionPlan) GenericDDLPlan(io.crate.planner.node.ddl.GenericDDLPlan) KillPlan(io.crate.planner.node.management.KillPlan) ESClusterUpdateSettingsPlan(io.crate.planner.node.ddl.ESClusterUpdateSettingsPlan) ExplainPlan(io.crate.planner.node.management.ExplainPlan) DropTablePlan(io.crate.planner.node.ddl.DropTablePlan) CreateAnalyzerPlan(io.crate.planner.node.ddl.CreateAnalyzerPlan)

Example 2 with ConsumerContext

use of io.crate.planner.consumer.ConsumerContext in project crate by crate.

the class SelectStatementPlanner method subPlan.

private static Plan subPlan(AnalyzedRelation rel, Planner.Context context) {
    ConsumerContext consumerContext = new ConsumerContext(context);
    Plan subPlan = context.planSubRelation(rel, consumerContext);
    assert subPlan != null : "plan must not be null";
    ValidationException validationException = consumerContext.validationException();
    if (validationException != null) {
        throw validationException;
    }
    return subPlan;
}
Also used : ValidationException(io.crate.exceptions.ValidationException) ConsumerContext(io.crate.planner.consumer.ConsumerContext)

Example 3 with ConsumerContext

use of io.crate.planner.consumer.ConsumerContext in project crate by crate.

the class CopyStatementPlanner method planCopyTo.

public Plan planCopyTo(CopyToAnalyzedStatement statement, Planner.Context context) {
    WriterProjection.OutputFormat outputFormat = statement.outputFormat();
    if (outputFormat == null) {
        outputFormat = statement.columnsDefined() ? WriterProjection.OutputFormat.JSON_ARRAY : WriterProjection.OutputFormat.JSON_OBJECT;
    }
    WriterProjection projection = ProjectionBuilder.writerProjection(statement.subQueryRelation().querySpec().outputs(), statement.uri(), statement.compressionType(), statement.overwrites(), statement.outputNames(), outputFormat);
    Plan plan = context.planSubRelation(statement.subQueryRelation(), new ConsumerContext(context));
    if (plan == null) {
        return null;
    }
    plan.addProjection(projection, null, null, 1, null);
    return Merge.ensureOnHandler(plan, context, Collections.singletonList(MergeCountProjection.INSTANCE));
}
Also used : WriterProjection(io.crate.planner.projection.WriterProjection) SourceIndexWriterProjection(io.crate.planner.projection.SourceIndexWriterProjection) ConsumerContext(io.crate.planner.consumer.ConsumerContext) Plan(io.crate.planner.Plan)

Aggregations

ConsumerContext (io.crate.planner.consumer.ConsumerContext)3 ValidationException (io.crate.exceptions.ValidationException)1 Plan (io.crate.planner.Plan)1 CreateAnalyzerPlan (io.crate.planner.node.ddl.CreateAnalyzerPlan)1 DropTablePlan (io.crate.planner.node.ddl.DropTablePlan)1 ESClusterUpdateSettingsPlan (io.crate.planner.node.ddl.ESClusterUpdateSettingsPlan)1 GenericDDLPlan (io.crate.planner.node.ddl.GenericDDLPlan)1 ExplainPlan (io.crate.planner.node.management.ExplainPlan)1 GenericShowPlan (io.crate.planner.node.management.GenericShowPlan)1 KillPlan (io.crate.planner.node.management.KillPlan)1 SourceIndexWriterProjection (io.crate.planner.projection.SourceIndexWriterProjection)1 WriterProjection (io.crate.planner.projection.WriterProjection)1 SetSessionPlan (io.crate.planner.statement.SetSessionPlan)1