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

Method parseDml0

core/src/main/java/io/questdb/griffin/SqlParser.java:2474–2645  ·  view source on GitHub ↗
(
            GenericLexer lexer,
            @Nullable LowerCaseCharSequenceObjHashMap<WithClauseModel> parentWithClauses,
            @Nullable LowerCaseCharSequenceObjHashMap<WithClauseModel> topWithClauses,
            int modelPosition,
            SqlParserCallback sqlParserCallback,
            @Nullable LowerCaseCharSequenceObjHashMap<ExpressionNode> decls,
            boolean overrideDeclare
    )

Source from the content-addressed store, hash-verified

2472 }
2473
2474 @NotNull
2475 private IQueryModel parseDml0(
2476 GenericLexer lexer,
2477 @Nullable LowerCaseCharSequenceObjHashMap<WithClauseModel> parentWithClauses,
2478 @Nullable LowerCaseCharSequenceObjHashMap<WithClauseModel> topWithClauses,
2479 int modelPosition,
2480 SqlParserCallback sqlParserCallback,
2481 @Nullable LowerCaseCharSequenceObjHashMap<ExpressionNode> decls,
2482 boolean overrideDeclare
2483 ) throws SqlException {
2484 CharSequence tok;
2485 IQueryModel model = queryModelPool.next();
2486 model.setModelPosition(modelPosition);
2487
2488 if (parentWithClauses != null) {
2489 model.getWithClauses().putAll(parentWithClauses);
2490 }
2491
2492 tok = tok(lexer, "'select', 'with', 'declare' or table name expected");
2493
2494 // [declare]
2495 if (isDeclareKeyword(tok)) {
2496 parseDeclare(lexer, model, sqlParserCallback);
2497 tok = tok(lexer, "'select', 'with', or table name expected");
2498 }
2499
2500 // Merge external declares with the query's own declares.
2501 // When there is a naming conflict, overrideDeclare controls the behavior:
2502 // - true: external declares override the query's own declares
2503 // - false: query's own declares take precedence over the external ones
2504 // Currently set to true at view boundaries only, allowing callers to parameterize views.
2505 model.copyDeclsFrom(decls, overrideDeclare);
2506
2507 // [with]
2508 if (isWithKeyword(tok)) {
2509 parseWithClauses(lexer, model.getWithClauses(), sqlParserCallback, model.getDecls());
2510 tok = tok(lexer, "'select' or table name expected");
2511 } else if (topWithClauses != null) {
2512 model.getWithClauses().putAll(topWithClauses);
2513 }
2514
2515 // [select]
2516 if (isSelectKeyword(tok)) {
2517 parseSelectClause(lexer, model, sqlParserCallback);
2518
2519 tok = optTok(lexer);
2520
2521 if (tok != null && setOperations.contains(tok)) {
2522 tok = null;
2523 }
2524
2525 if (tok == null || Chars.equals(tok, ';') || Chars.equals(tok, ')')) { // token can also be ';' on query boundary
2526 IQueryModel nestedModel = queryModelPool.next();
2527 nestedModel.setModelPosition(modelPosition);
2528 ExpressionNode tableNameExpr = expressionNodePool.next().of(ExpressionNode.FUNCTION, "long_sequence", 0, lexer.lastTokenPosition());
2529 tableNameExpr.paramCount = 1;
2530 tableNameExpr.rhs = ONE;
2531 nestedModel.setTableNameExpr(tableNameExpr);

Callers 1

parseDmlMethod · 0.95

Calls 15

setModelPositionMethod · 0.95
getWithClausesMethod · 0.95
tokMethod · 0.95
parseDeclareMethod · 0.95
copyDeclsFromMethod · 0.95
parseWithClausesMethod · 0.95
getDeclsMethod · 0.95
parseSelectClauseMethod · 0.95
optTokMethod · 0.95
equalsMethod · 0.95
setTableNameExprMethod · 0.95
setSelectModelTypeMethod · 0.95

Tested by

no test coverage detected