Search in sources :

Example 1 with ClickhouseCreateTableStatement

use of com.alibaba.druid.sql.dialect.clickhouse.ast.ClickhouseCreateTableStatement in project druid by alibaba.

the class ClickhouseCreateTableParser method parseCreateTableRest.

protected void parseCreateTableRest(SQLCreateTableStatement stmt) {
    ClickhouseCreateTableStatement ckStmt = (ClickhouseCreateTableStatement) stmt;
    if (lexer.identifierEquals(FnvHash.Constants.ENGINE)) {
        lexer.nextToken();
        if (lexer.token() == Token.EQ) {
            lexer.nextToken();
        }
        stmt.setEngine(this.exprParser.expr());
    }
    if (lexer.identifierEquals("PARTITION")) {
        lexer.nextToken();
        accept(Token.BY);
        SQLExpr expr = this.exprParser.expr();
        ckStmt.setPartitionBy(expr);
    }
    if (lexer.token() == Token.ORDER) {
        SQLOrderBy orderBy = this.exprParser.parseOrderBy();
        ckStmt.setOrderBy(orderBy);
    }
    if (lexer.identifierEquals("SAMPLE")) {
        lexer.nextToken();
        accept(Token.BY);
        SQLExpr expr = this.exprParser.expr();
        ckStmt.setSampleBy(expr);
    }
    if (lexer.identifierEquals("SETTINGS")) {
        lexer.nextToken();
        for (; ; ) {
            SQLAssignItem item = this.exprParser.parseAssignItem();
            item.setParent(ckStmt);
            ckStmt.getSettings().add(item);
            if (lexer.token() == Token.COMMA) {
                lexer.nextToken();
                continue;
            }
            break;
        }
    }
}
Also used : SQLOrderBy(com.alibaba.druid.sql.ast.SQLOrderBy) SQLAssignItem(com.alibaba.druid.sql.ast.statement.SQLAssignItem) ClickhouseCreateTableStatement(com.alibaba.druid.sql.dialect.clickhouse.ast.ClickhouseCreateTableStatement) SQLExpr(com.alibaba.druid.sql.ast.SQLExpr)

Aggregations

SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)1 SQLOrderBy (com.alibaba.druid.sql.ast.SQLOrderBy)1 SQLAssignItem (com.alibaba.druid.sql.ast.statement.SQLAssignItem)1 ClickhouseCreateTableStatement (com.alibaba.druid.sql.dialect.clickhouse.ast.ClickhouseCreateTableStatement)1