Search in sources :

Example 1 with SQLSubPartitionByList

use of com.alibaba.druid.sql.ast.SQLSubPartitionByList in project druid by alibaba.

the class OracleCreateTableParser method subPartitionBy.

protected SQLSubPartitionBy subPartitionBy() {
    lexer.nextToken();
    accept(Token.BY);
    if (identifierEquals("HASH")) {
        lexer.nextToken();
        accept(Token.LPAREN);
        SQLSubPartitionByHash byHash = new SQLSubPartitionByHash();
        SQLExpr expr = this.exprParser.expr();
        byHash.setExpr(expr);
        accept(Token.RPAREN);
        return byHash;
    } else if (identifierEquals("LIST")) {
        lexer.nextToken();
        accept(Token.LPAREN);
        SQLSubPartitionByList byList = new SQLSubPartitionByList();
        SQLName column = this.exprParser.name();
        byList.setColumn(column);
        accept(Token.RPAREN);
        if (identifierEquals("SUBPARTITION")) {
            lexer.nextToken();
            acceptIdentifier("TEMPLATE");
            accept(Token.LPAREN);
            for (; ; ) {
                SQLSubPartition subPartition = parseSubPartition();
                subPartition.setParent(byList);
                byList.getSubPartitionTemplate().add(subPartition);
                if (lexer.token() == Token.COMMA) {
                    lexer.nextToken();
                    continue;
                }
                break;
            }
            accept(Token.RPAREN);
        }
        return byList;
    }
    throw new ParserException("TODO : " + lexer.token() + " " + lexer.stringVal());
}
Also used : SQLSubPartitionByList(com.alibaba.druid.sql.ast.SQLSubPartitionByList) ParserException(com.alibaba.druid.sql.parser.ParserException) SQLSubPartition(com.alibaba.druid.sql.ast.SQLSubPartition) SQLSubPartitionByHash(com.alibaba.druid.sql.ast.SQLSubPartitionByHash) SQLName(com.alibaba.druid.sql.ast.SQLName) SQLExpr(com.alibaba.druid.sql.ast.SQLExpr)

Aggregations

SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)1 SQLName (com.alibaba.druid.sql.ast.SQLName)1 SQLSubPartition (com.alibaba.druid.sql.ast.SQLSubPartition)1 SQLSubPartitionByHash (com.alibaba.druid.sql.ast.SQLSubPartitionByHash)1 SQLSubPartitionByList (com.alibaba.druid.sql.ast.SQLSubPartitionByList)1 ParserException (com.alibaba.druid.sql.parser.ParserException)1