Search in sources :

Example 1 with FetchRewrite

use of io.crate.planner.operators.FetchRewrite in project crate by crate.

the class RewriteToQueryThenFetch method apply.

@Override
public LogicalPlan apply(Limit limit, Captures captures, TableStats tableStats, TransactionContext txnCtx, NodeContext nodeCtx) {
    if (Symbols.containsColumn(limit.outputs(), DocSysColumns.FETCHID)) {
        return null;
    }
    FetchRewrite fetchRewrite = limit.source().rewriteToFetch(tableStats, Set.of());
    if (fetchRewrite == null) {
        return null;
    }
    List<Reference> fetchRefs = fetchRewrite.extractFetchRefs();
    Map<RelationName, FetchSource> fetchSourceByRelation = fetchRewrite.createFetchSources();
    return new Fetch(fetchRewrite.replacedOutputs(), fetchRefs, fetchSourceByRelation, limit.replaceSources(List.of(fetchRewrite.newPlan())));
}
Also used : Fetch(io.crate.planner.operators.Fetch) FetchRewrite(io.crate.planner.operators.FetchRewrite) FetchSource(io.crate.planner.node.fetch.FetchSource) Reference(io.crate.metadata.Reference) RelationName(io.crate.metadata.RelationName)

Example 2 with FetchRewrite

use of io.crate.planner.operators.FetchRewrite in project crate by crate.

the class RewriteToQueryThenFetch method doRewrite.

private static LogicalPlan doRewrite(AnalyzedRelation relation, LogicalPlan plan, TableStats tableStats) {
    FetchRewrite fetchRewrite = plan.rewriteToFetch(tableStats, List.of());
    if (fetchRewrite == null) {
        return plan;
    }
    List<Reference> fetchRefs = fetchRewrite.extractFetchRefs();
    Map<RelationName, FetchSource> fetchSourceByRelation = fetchRewrite.createFetchSources();
    Fetch fetch = new Fetch(fetchRewrite.replacedOutputs(), fetchRefs, fetchSourceByRelation, fetchRewrite.newPlan());
    return Eval.create(fetch, relation.outputs());
}
Also used : Fetch(io.crate.planner.operators.Fetch) FetchRewrite(io.crate.planner.operators.FetchRewrite) FetchSource(io.crate.planner.node.fetch.FetchSource) Reference(io.crate.metadata.Reference) RelationName(io.crate.metadata.RelationName)

Aggregations

Reference (io.crate.metadata.Reference)2 RelationName (io.crate.metadata.RelationName)2 FetchSource (io.crate.planner.node.fetch.FetchSource)2 Fetch (io.crate.planner.operators.Fetch)2 FetchRewrite (io.crate.planner.operators.FetchRewrite)2