MCPcopy Create free account
hub / github.com/questdb/questdb / parseJoin

Method parseJoin

core/src/main/java/io/questdb/griffin/SqlParser.java:3438–3816  ·  view source on GitHub ↗
(
            GenericLexer lexer,
            IQueryModel model,
            CharSequence tok,
            int joinType,
            LowerCaseCharSequenceObjHashMap<WithClauseModel> parent,
            SqlParserCallback sqlParserCallback,
            @Nullable LowerCaseCharSequenceObjHashMap<ExpressionNode> decls
    )

Source from the content-addressed store, hash-verified

3436 }
3437
3438 private IQueryModel parseJoin(
3439 GenericLexer lexer,
3440 IQueryModel model,
3441 CharSequence tok,
3442 int joinType,
3443 LowerCaseCharSequenceObjHashMap<WithClauseModel> parent,
3444 SqlParserCallback sqlParserCallback,
3445 @Nullable LowerCaseCharSequenceObjHashMap<ExpressionNode> decls
3446 ) throws SqlException {
3447 int errorPos = lexer.lastTokenPosition();
3448
3449 if (isNotJoinKeyword(tok) && !Chars.equals(tok, ',')) {
3450 // not already a join?
3451 // was it "left", "right", "full" or window?
3452 if (isLeftKeyword(tok)) {
3453 tok = tok(lexer, "join");
3454 joinType = IQueryModel.JOIN_LEFT_OUTER;
3455 if (isOuterKeyword(tok)) {
3456 tok = tok(lexer, "join");
3457 }
3458 } else if (isRightKeyword(tok)) {
3459 tok = tok(lexer, "join");
3460 joinType = IQueryModel.JOIN_RIGHT_OUTER;
3461 if (isOuterKeyword(tok)) {
3462 tok = tok(lexer, "join");
3463 }
3464 } else if (isFullKeyword(tok)) {
3465 tok = tok(lexer, "join");
3466 joinType = IQueryModel.JOIN_FULL_OUTER;
3467 if (isOuterKeyword(tok)) {
3468 tok = tok(lexer, "join");
3469 }
3470 } else if (isWindowKeyword(tok)) {
3471 tok = tok(lexer, "join");
3472 joinType = IQueryModel.JOIN_WINDOW;
3473 } else if (isHorizonKeyword(tok)) {
3474 tok = tok(lexer, "join");
3475 joinType = IQueryModel.JOIN_HORIZON;
3476 } else if (isLateralKeyword(tok)) {
3477 joinType = IQueryModel.JOIN_LATERAL_CROSS;
3478 } else {
3479 tok = tok(lexer, "join");
3480 }
3481 if (joinType != IQueryModel.JOIN_LATERAL_CROSS && isNotJoinKeyword(tok)) {
3482 throw SqlException.position(errorPos).put("'join' expected");
3483 }
3484 }
3485
3486 tok = expectTableNameOrSubQuery(lexer);
3487
3488 // UNNEST in comma position: FROM t, UNNEST(...)
3489 if (isUnnestKeyword(tok) && joinType == QueryModel.JOIN_CROSS) {
3490 return parseUnnest(lexer, model, decls, sqlParserCallback);
3491 }
3492
3493 if (isLateralKeyword(tok) && joinType != IQueryModel.JOIN_LATERAL_CROSS) {
3494 joinType = switch (joinType) {
3495 case IQueryModel.JOIN_LEFT_OUTER -> IQueryModel.JOIN_LATERAL_LEFT;

Callers 2

parseDmlUpdateMethod · 0.95
parseFromClauseMethod · 0.95

Calls 15

equalsMethod · 0.95
tokMethod · 0.95
positionMethod · 0.95
parseUnnestMethod · 0.95
isLateralJoinMethod · 0.95
copyDeclsFromMethod · 0.95
setJoinTypeMethod · 0.95
isViewMethod · 0.95
compileViewQueryMethod · 0.95
setNestedModelMethod · 0.95

Tested by

no test coverage detected