Search in sources :

Example 11 with SQLSubqueryTableSource

use of com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource in project druid by alibaba.

the class OdpsStatementParser method parseInsert.

public SQLStatement parseInsert() {
    OdpsInsertStatement stmt = new OdpsInsertStatement();
    if (lexer.token() == Token.FROM) {
        lexer.nextToken();
        if (lexer.token() == Token.IDENTIFIER) {
            SQLName tableName = this.exprParser.name();
            SQLExprTableSource from = new SQLExprTableSource(tableName);
            stmt.setFrom(from);
        } else {
            accept(Token.LPAREN);
            SQLSelectParser selectParser = createSQLSelectParser();
            SQLSelect select = selectParser.select();
            accept(Token.RPAREN);
            String alias = lexer.stringVal();
            accept(Token.IDENTIFIER);
            SQLSubqueryTableSource from = new SQLSubqueryTableSource(select, alias);
            stmt.setFrom(from);
        }
    }
    for (; ; ) {
        OdpsInsert insert = parseOdpsInsert();
        stmt.addItem(insert);
        if (lexer.token() != Token.INSERT) {
            break;
        }
    }
    return stmt;
}
Also used : SQLSubqueryTableSource(com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource) SQLSelectParser(com.alibaba.druid.sql.parser.SQLSelectParser) SQLSelect(com.alibaba.druid.sql.ast.statement.SQLSelect) SQLName(com.alibaba.druid.sql.ast.SQLName) SQLExprTableSource(com.alibaba.druid.sql.ast.statement.SQLExprTableSource) OdpsInsert(com.alibaba.druid.sql.dialect.odps.ast.OdpsInsert) OdpsInsertStatement(com.alibaba.druid.sql.dialect.odps.ast.OdpsInsertStatement)

Aggregations

SQLSubqueryTableSource (com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource)11 SQLBinaryOpExpr (com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr)8 SQLSelectItem (com.alibaba.druid.sql.ast.statement.SQLSelectItem)8 SQLSelectQuery (com.alibaba.druid.sql.ast.statement.SQLSelectQuery)8 SQLSelect (com.alibaba.druid.sql.ast.statement.SQLSelect)7 SQLOrderBy (com.alibaba.druid.sql.ast.SQLOrderBy)5 SQLAggregateExpr (com.alibaba.druid.sql.ast.expr.SQLAggregateExpr)5 SQLIntegerExpr (com.alibaba.druid.sql.ast.expr.SQLIntegerExpr)5 SQLSelectQueryBlock (com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock)5 SQLTableSource (com.alibaba.druid.sql.ast.statement.SQLTableSource)5 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)4 SQLBinaryOperator (com.alibaba.druid.sql.ast.expr.SQLBinaryOperator)4 SQLIdentifierExpr (com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr)4 OracleSelectQueryBlock (com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleSelectQueryBlock)4 SQLAllColumnExpr (com.alibaba.druid.sql.ast.expr.SQLAllColumnExpr)3 SQLNumberExpr (com.alibaba.druid.sql.ast.expr.SQLNumberExpr)3 SQLPropertyExpr (com.alibaba.druid.sql.ast.expr.SQLPropertyExpr)3 SQLOver (com.alibaba.druid.sql.ast.SQLOver)2 SQLExprTableSource (com.alibaba.druid.sql.ast.statement.SQLExprTableSource)2 SQLSelectStatement (com.alibaba.druid.sql.ast.statement.SQLSelectStatement)2