Package com.alibaba.druid.sql.dialect.postgresql.ast

Examples of com.alibaba.druid.sql.dialect.postgresql.ast.PGAggregateExpr


    public PGExprParser(Lexer lexer){
        super(lexer);
    }
   
    protected SQLAggregateExpr parseAggregateExpr(String method_name) throws ParserException {
        PGAggregateExpr aggregateExpr;
        if (lexer.token() == Token.ALL) {
            aggregateExpr = new PGAggregateExpr(method_name, 1);
            lexer.nextToken();
        } else if (lexer.token() == Token.DISTINCT) {
            aggregateExpr = new PGAggregateExpr(method_name, 0);
            lexer.nextToken();
        } else {
            aggregateExpr = new PGAggregateExpr(method_name, 1);
        }

        exprList(aggregateExpr.getArguments());

        accept(Token.RPAREN);
       
        if (lexer.token() == Token.OVER) {
          lexer.nextToken();
          PGAnalytic over = new PGAnalytic();
          accept(Token.LPAREN);
         
            if (identifierEquals("PARTITION")) {
                lexer.nextToken();
                accept(Token.BY);

                if (lexer.token() == (Token.LPAREN)) {
                    lexer.nextToken();
                    exprList(over.getPartitionBy());
                    accept(Token.RPAREN);
                } else {
                    exprList(over.getPartitionBy());
                }
            }


            over.setOrderBy(parseOrderBy());
           
            if (over.getOrderBy() != null) {
              //TODO window
            }
         
          accept(Token.RPAREN);
          aggregateExpr.setOver(over);

        }
       
        return aggregateExpr;
    }
View Full Code Here


    }
   
    protected SQLAggregateExpr parseAggregateExpr(String methodName) throws ParserException {
        methodName = methodName.toUpperCase();
       
        PGAggregateExpr aggregateExpr;
        if (lexer.token() == Token.ALL) {
            aggregateExpr = new PGAggregateExpr(methodName, SQLAggregateExpr.Option.ALL);
            lexer.nextToken();
        } else if (lexer.token() == Token.DISTINCT) {
            aggregateExpr = new PGAggregateExpr(methodName, SQLAggregateExpr.Option.DISTINCT);
            lexer.nextToken();
        } else {
            aggregateExpr = new PGAggregateExpr(methodName);
        }

        exprList(aggregateExpr.getArguments());

        accept(Token.RPAREN);
       
        if (lexer.token() == Token.OVER) {
          lexer.nextToken();
          PGAnalytic over = new PGAnalytic();
          accept(Token.LPAREN);
         
            if (identifierEquals("PARTITION")) {
                lexer.nextToken();
                accept(Token.BY);

                if (lexer.token() == (Token.LPAREN)) {
                    lexer.nextToken();
                    exprList(over.getPartitionBy());
                    accept(Token.RPAREN);
                } else {
                    exprList(over.getPartitionBy());
                }
            }


            over.setOrderBy(parseOrderBy());
           
            if (over.getOrderBy() != null) {
              //TODO window
            }
         
          accept(Token.RPAREN);
          aggregateExpr.setOver(over);

        }
       
        return aggregateExpr;
    }
View Full Code Here

    }
   
    protected SQLAggregateExpr parseAggregateExpr(String methodName)  {
        methodName = methodName.toUpperCase();
       
        PGAggregateExpr aggregateExpr;
        if (lexer.token() == Token.ALL) {
            aggregateExpr = new PGAggregateExpr(methodName, SQLAggregateExpr.Option.ALL);
            lexer.nextToken();
        } else if (lexer.token() == Token.DISTINCT) {
            aggregateExpr = new PGAggregateExpr(methodName, SQLAggregateExpr.Option.DISTINCT);
            lexer.nextToken();
        } else {
            aggregateExpr = new PGAggregateExpr(methodName);
        }

        exprList(aggregateExpr.getArguments());

        accept(Token.RPAREN);
       
        if (lexer.token() == Token.OVER) {
          lexer.nextToken();
          PGAnalytic over = new PGAnalytic();
          accept(Token.LPAREN);
         
            if (identifierEquals("PARTITION")) {
                lexer.nextToken();
                accept(Token.BY);

                if (lexer.token() == (Token.LPAREN)) {
                    lexer.nextToken();
                    exprList(over.getPartitionBy());
                    accept(Token.RPAREN);
                } else {
                    exprList(over.getPartitionBy());
                }
            }


            over.setOrderBy(parseOrderBy());
           
            // if (over.getOrderBy() != null) {
            // //TODO window
            // }
         
          accept(Token.RPAREN);
          aggregateExpr.setOver(over);

        }
       
        return aggregateExpr;
    }
View Full Code Here

    public PGExprParser(Lexer lexer){
        super(lexer);
    }
   
    protected SQLAggregateExpr parseAggregateExpr(String method_name) throws ParserException {
        PGAggregateExpr aggregateExpr;
        if (lexer.token() == Token.ALL) {
            aggregateExpr = new PGAggregateExpr(method_name, 1);
            lexer.nextToken();
        } else if (lexer.token() == Token.DISTINCT) {
            aggregateExpr = new PGAggregateExpr(method_name, 0);
            lexer.nextToken();
        } else {
            aggregateExpr = new PGAggregateExpr(method_name, 1);
        }

        exprList(aggregateExpr.getArguments());

        accept(Token.RPAREN);
       
        if (lexer.token() == Token.OVER) {
          lexer.nextToken();
          PGAnalytic over = new PGAnalytic();
          accept(Token.LPAREN);
         
            if (identifierEquals("PARTITION")) {
                lexer.nextToken();
                accept(Token.BY);

                if (lexer.token() == (Token.LPAREN)) {
                    lexer.nextToken();
                    exprList(over.getPartitionBy());
                    accept(Token.RPAREN);
                } else {
                    exprList(over.getPartitionBy());
                }
            }


            over.setOrderBy(parseOrderBy());
           
            if (over.getOrderBy() != null) {
              //TODO window
            }
         
          accept(Token.RPAREN);
          aggregateExpr.setOver(over);

        }
       
        return aggregateExpr;
    }
View Full Code Here

TOP

Related Classes of com.alibaba.druid.sql.dialect.postgresql.ast.PGAggregateExpr

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.