Search in sources :

Example 1 with OdpsShowGrantsStmt

use of com.alibaba.druid.sql.dialect.odps.ast.OdpsShowGrantsStmt in project druid by alibaba.

the class OdpsStatementParser method parseShow.

public SQLStatement parseShow() {
    accept(Token.SHOW);
    if (identifierEquals("PARTITIONS")) {
        lexer.nextToken();
        OdpsShowPartitionsStmt stmt = new OdpsShowPartitionsStmt();
        SQLExpr expr = this.exprParser.expr();
        stmt.setTableSource(new SQLExprTableSource(expr));
        return stmt;
    }
    if (identifierEquals("STATISTIC")) {
        lexer.nextToken();
        OdpsShowStatisticStmt stmt = new OdpsShowStatisticStmt();
        SQLExpr expr = this.exprParser.expr();
        stmt.setTableSource(new SQLExprTableSource(expr));
        return stmt;
    }
    if (identifierEquals("TABLES")) {
        lexer.nextToken();
        SQLShowTablesStatement stmt = new SQLShowTablesStatement();
        if (lexer.token() == Token.FROM) {
            lexer.nextToken();
            stmt.setDatabase(this.exprParser.name());
        }
        if (lexer.token() == Token.LIKE) {
            lexer.nextToken();
            stmt.setLike(this.exprParser.expr());
        }
        return stmt;
    }
    if (identifierEquals("GRANTS")) {
        lexer.nextToken();
        OdpsShowGrantsStmt stmt = new OdpsShowGrantsStmt();
        if (lexer.token() == Token.FOR) {
            lexer.nextToken();
            stmt.setUser(this.exprParser.expr());
        }
        if (lexer.token() == Token.ON) {
            lexer.nextToken();
            acceptIdentifier("type");
            stmt.setObjectType(this.exprParser.expr());
        }
        return stmt;
    }
    throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
}
Also used : ParserException(com.alibaba.druid.sql.parser.ParserException) OdpsShowStatisticStmt(com.alibaba.druid.sql.dialect.odps.ast.OdpsShowStatisticStmt) SQLShowTablesStatement(com.alibaba.druid.sql.ast.statement.SQLShowTablesStatement) SQLExprTableSource(com.alibaba.druid.sql.ast.statement.SQLExprTableSource) OdpsShowGrantsStmt(com.alibaba.druid.sql.dialect.odps.ast.OdpsShowGrantsStmt) OdpsShowPartitionsStmt(com.alibaba.druid.sql.dialect.odps.ast.OdpsShowPartitionsStmt) SQLExpr(com.alibaba.druid.sql.ast.SQLExpr)

Aggregations

SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)1 SQLExprTableSource (com.alibaba.druid.sql.ast.statement.SQLExprTableSource)1 SQLShowTablesStatement (com.alibaba.druid.sql.ast.statement.SQLShowTablesStatement)1 OdpsShowGrantsStmt (com.alibaba.druid.sql.dialect.odps.ast.OdpsShowGrantsStmt)1 OdpsShowPartitionsStmt (com.alibaba.druid.sql.dialect.odps.ast.OdpsShowPartitionsStmt)1 OdpsShowStatisticStmt (com.alibaba.druid.sql.dialect.odps.ast.OdpsShowStatisticStmt)1 ParserException (com.alibaba.druid.sql.parser.ParserException)1