Search in sources :

Example 1 with ValidationException

use of io.crate.exceptions.ValidationException 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 2 with ValidationException

use of io.crate.exceptions.ValidationException 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)

Example 3 with ValidationException

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

the class RelationAnalyzer method visitJoin.

@Override
protected AnalyzedRelation visitJoin(Join node, StatementAnalysisContext statementContext) {
    process(node.getLeft(), statementContext);
    process(node.getRight(), statementContext);
    RelationAnalysisContext relationContext = statementContext.currentRelationContext();
    Optional<JoinCriteria> optCriteria = node.getCriteria();
    Symbol joinCondition = null;
    if (optCriteria.isPresent()) {
        JoinCriteria joinCriteria = optCriteria.get();
        if (joinCriteria instanceof JoinOn) {
            ExpressionAnalyzer expressionAnalyzer = new ExpressionAnalyzer(functions, statementContext.sessionContext(), statementContext.convertParamFunction(), new FullQualifedNameFieldProvider(relationContext.sources()), new SubqueryAnalyzer(this, statementContext));
            try {
                joinCondition = expressionAnalyzer.convert(((JoinOn) joinCriteria).getExpression(), relationContext.expressionAnalysisContext());
            } catch (RelationUnknownException e) {
                throw new ValidationException(String.format(Locale.ENGLISH, "missing FROM-clause entry for relation '%s'", e.qualifiedName()));
            }
        } else {
            throw new UnsupportedOperationException(String.format(Locale.ENGLISH, "join criteria %s not supported", joinCriteria.getClass().getSimpleName()));
        }
    }
    relationContext.addJoinType(JoinType.values()[node.getType().ordinal()], joinCondition);
    return null;
}
Also used : RelationUnknownException(io.crate.exceptions.RelationUnknownException) ValidationException(io.crate.exceptions.ValidationException) Symbol(io.crate.analyze.symbol.Symbol) ExpressionAnalyzer(io.crate.analyze.expressions.ExpressionAnalyzer) SubqueryAnalyzer(io.crate.analyze.expressions.SubqueryAnalyzer)

Aggregations

ValidationException (io.crate.exceptions.ValidationException)3 QuerySpec (io.crate.analyze.QuerySpec)1 ExpressionAnalyzer (io.crate.analyze.expressions.ExpressionAnalyzer)1 SubqueryAnalyzer (io.crate.analyze.expressions.SubqueryAnalyzer)1 QueriedRelation (io.crate.analyze.relations.QueriedRelation)1 SelectSymbol (io.crate.analyze.symbol.SelectSymbol)1 Symbol (io.crate.analyze.symbol.Symbol)1 RelationUnknownException (io.crate.exceptions.RelationUnknownException)1 ConsumerContext (io.crate.planner.consumer.ConsumerContext)1 Nullable (javax.annotation.Nullable)1