Search in sources :

Example 1 with SelectSymbol

use of io.crate.analyze.symbol.SelectSymbol in project crate by crate.

the class SubSelectSymbolReplacerTest method testSelectSymbolsAreReplacedInSelectListOfPrimaryKeyLookups.

@Test
public void testSelectSymbolsAreReplacedInSelectListOfPrimaryKeyLookups() throws Exception {
    MultiPhasePlan plan = e.plan("select (select 'foo' from sys.cluster) from users where id = 10");
    ESGet esGet = (ESGet) plan.rootPlan();
    SelectSymbol subSelect = (SelectSymbol) esGet.outputs().get(0);
    SubSelectSymbolReplacer replacer = new SubSelectSymbolReplacer(esGet, subSelect);
    replacer.onSuccess(new BytesRef("foo"));
    assertThat(esGet.outputs(), contains(isLiteral("foo")));
}
Also used : SelectSymbol(io.crate.analyze.symbol.SelectSymbol) ESGet(io.crate.planner.node.dql.ESGet) MultiPhasePlan(io.crate.planner.MultiPhasePlan) BytesRef(org.apache.lucene.util.BytesRef) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 2 with SelectSymbol

use of io.crate.analyze.symbol.SelectSymbol in project crate by crate.

the class ConsumingPlanner method plan.

@Nullable
public Plan plan(AnalyzedRelation relation, ConsumerContext consumerContext) {
    for (Consumer consumer : consumers) {
        Plan plan = consumer.consume(relation, consumerContext);
        if (plan != null) {
            if (relation instanceof QueriedRelation) {
                QuerySpec qs = ((QueriedRelation) relation).querySpec();
                SubqueryPlanner subqueryPlanner = new SubqueryPlanner(consumerContext.plannerContext());
                Map<Plan, SelectSymbol> subQueries = subqueryPlanner.planSubQueries(qs);
                return MultiPhasePlan.createIfNeeded(plan, subQueries);
            }
            return plan;
        }
    }
    ValidationException validationException = consumerContext.validationException();
    if (validationException != null) {
        throw validationException;
    }
    return null;
}
Also used : SelectSymbol(io.crate.analyze.symbol.SelectSymbol) ValidationException(io.crate.exceptions.ValidationException) QueriedRelation(io.crate.analyze.relations.QueriedRelation) QuerySpec(io.crate.analyze.QuerySpec) Nullable(javax.annotation.Nullable)

Aggregations

SelectSymbol (io.crate.analyze.symbol.SelectSymbol)2 QuerySpec (io.crate.analyze.QuerySpec)1 QueriedRelation (io.crate.analyze.relations.QueriedRelation)1 ValidationException (io.crate.exceptions.ValidationException)1 MultiPhasePlan (io.crate.planner.MultiPhasePlan)1 ESGet (io.crate.planner.node.dql.ESGet)1 CrateUnitTest (io.crate.test.integration.CrateUnitTest)1 Nullable (javax.annotation.Nullable)1 BytesRef (org.apache.lucene.util.BytesRef)1 Test (org.junit.Test)1