use of io.crate.analyze.expressions.ExpressionAnalyzer 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