use of io.crate.sql.tree.NaturalJoin in project crate by crate.
the class AstBuilder method visitJoinRelation.
// From clause
@Override
public Node visitJoinRelation(SqlBaseParser.JoinRelationContext context) {
Relation left = (Relation) visit(context.left);
Relation right;
if (context.CROSS() != null) {
right = (Relation) visit(context.right);
return new Join(Join.Type.CROSS, left, right, Optional.empty());
}
JoinCriteria criteria;
if (context.NATURAL() != null) {
right = (Relation) visit(context.right);
criteria = new NaturalJoin();
} else {
right = (Relation) visit(context.rightRelation);
if (context.joinCriteria().ON() != null) {
criteria = new JoinOn((Expression) visit(context.joinCriteria().booleanExpression()));
} else if (context.joinCriteria().USING() != null) {
List<String> columns = identsToStrings(context.joinCriteria().ident());
criteria = new JoinUsing(columns);
} else {
throw new IllegalArgumentException("Unsupported join criteria");
}
}
return new Join(getJoinType(context.joinType()), left, right, Optional.of(criteria));
}
Aggregations