Search in sources :

Example 1 with VersionInvalidException

use of io.crate.exceptions.VersionInvalidException in project crate by crate.

the class ESGetStatementPlanner method convert.

public static Plan convert(QueriedDocTable table, Planner.Context context) {
    QuerySpec querySpec = table.querySpec();
    Optional<DocKeys> optKeys = querySpec.where().docKeys();
    assert !querySpec.hasAggregates() : "Can't create ESGet plan for queries with aggregates";
    assert !querySpec.groupBy().isPresent() : "Can't create ESGet plan for queries with group by";
    assert optKeys.isPresent() : "Can't create ESGet without docKeys";
    DocTableInfo tableInfo = table.tableRelation().tableInfo();
    DocKeys docKeys = optKeys.get();
    if (docKeys.withVersions()) {
        throw new VersionInvalidException();
    }
    Limits limits = context.getLimits(querySpec);
    if (limits.hasLimit() && limits.finalLimit() == 0) {
        return new NoopPlan(context.jobId());
    }
    table.tableRelation().validateOrderBy(querySpec.orderBy());
    return new ESGet(context.nextExecutionPhaseId(), tableInfo, querySpec.outputs(), optKeys.get(), querySpec.orderBy(), limits.finalLimit(), limits.offset(), context.jobId());
}
Also used : DocTableInfo(io.crate.metadata.doc.DocTableInfo) NoopPlan(io.crate.planner.NoopPlan) Limits(io.crate.planner.Limits) DocKeys(io.crate.analyze.where.DocKeys) ESGet(io.crate.planner.node.dql.ESGet) QuerySpec(io.crate.analyze.QuerySpec) VersionInvalidException(io.crate.exceptions.VersionInvalidException)

Aggregations

QuerySpec (io.crate.analyze.QuerySpec)1 DocKeys (io.crate.analyze.where.DocKeys)1 VersionInvalidException (io.crate.exceptions.VersionInvalidException)1 DocTableInfo (io.crate.metadata.doc.DocTableInfo)1 Limits (io.crate.planner.Limits)1 NoopPlan (io.crate.planner.NoopPlan)1 ESGet (io.crate.planner.node.dql.ESGet)1