[#7518] Support parsing CROSS JOIN [ ON | USING ]
This commit is contained in:
parent
af2c447bfe
commit
fbc8f05336
@ -476,8 +476,12 @@ tables = table { ',' table }
|
||||
table = lateral { unqualifiedJoin | innerJoin | outerJoin | semiAntiJoin }
|
||||
;
|
||||
|
||||
optionallyQualifiedJoin = 'CROSS JOIN'
|
||||
( table joinQualification | lateral )
|
||||
;
|
||||
|
||||
unqualifiedJoin =
|
||||
( 'CROSS JOIN' | 'CROSS APPLY' | 'OUTER APPLY' | 'NATURAL' [ ( 'LEFT' | 'RIGHT' ) [ 'OUTER' ] ] 'JOIN' )
|
||||
( 'CROSS APPLY' | 'OUTER APPLY' | 'NATURAL' [ ( 'LEFT' | 'RIGHT' | 'FULL' ) [ 'OUTER' ] ] 'JOIN' )
|
||||
lateral
|
||||
;
|
||||
|
||||
|
||||
@ -4132,24 +4132,34 @@ final class ParserImpl implements Parser {
|
||||
case STRAIGHT_JOIN:
|
||||
case LEFT_SEMI_JOIN:
|
||||
case LEFT_ANTI_JOIN:
|
||||
if (parseKeywordIf(ctx, "ON")) {
|
||||
if (parseKeywordIf(ctx, "ON"))
|
||||
return s2.on(parseCondition(ctx));
|
||||
}
|
||||
else if (parseKeywordIf(ctx, "USING")) {
|
||||
parse(ctx, '(');
|
||||
Table result = s2.using(Tools.fieldsByName(parseIdentifiers(ctx).toArray(EMPTY_NAME)));
|
||||
parse(ctx, ')');
|
||||
|
||||
return result;
|
||||
}
|
||||
else if (parseKeywordIf(ctx, "USING"))
|
||||
return parseJoinUsing(ctx, s2);
|
||||
else
|
||||
throw ctx.expected("ON", "USING");
|
||||
|
||||
case CROSS_JOIN:
|
||||
if (parseKeywordIf(ctx, "ON"))
|
||||
return left.join(right).on(parseCondition(ctx));
|
||||
else if (parseKeywordIf(ctx, "USING"))
|
||||
return parseJoinUsing(ctx, left.join(right));
|
||||
|
||||
// No break
|
||||
|
||||
default:
|
||||
return s0;
|
||||
}
|
||||
}
|
||||
|
||||
private static final Table<?> parseJoinUsing(ParserContext ctx, TableOnStep<?> join) {
|
||||
parse(ctx, '(');
|
||||
Table result = join.using(Tools.fieldsByName(parseIdentifiers(ctx).toArray(EMPTY_NAME)));
|
||||
parse(ctx, ')');
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static final List<SelectFieldOrAsterisk> parseSelectList(ParserContext ctx) {
|
||||
List<SelectFieldOrAsterisk> result = new ArrayList<SelectFieldOrAsterisk>();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user