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;
}
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;
}
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;
}
Aggregations