use of com.alibaba.druid.sql.dialect.odps.ast.OdpsUDTFSQLSelectItem in project druid by alibaba.
the class OdpsExprParser method parseSelectItem.
@Override
public SQLSelectItem parseSelectItem() {
SQLExpr expr;
if (lexer.token() == Token.IDENTIFIER) {
expr = new SQLIdentifierExpr(lexer.stringVal());
lexer.nextTokenComma();
if (lexer.token() != Token.COMMA) {
expr = this.primaryRest(expr);
expr = this.exprRest(expr);
}
} else {
expr = expr();
}
String alias = null;
if (lexer.token() == Token.AS) {
lexer.nextToken();
if (lexer.token() == Token.LPAREN) {
lexer.nextToken();
OdpsUDTFSQLSelectItem selectItem = new OdpsUDTFSQLSelectItem();
selectItem.setExpr(expr);
for (; ; ) {
alias = lexer.stringVal();
lexer.nextToken();
selectItem.getAliasList().add(alias);
if (lexer.token() == Token.COMMA) {
lexer.nextToken();
continue;
}
break;
}
accept(Token.RPAREN);
return selectItem;
} else {
alias = alias();
}
} else {
alias = as();
}
SQLSelectItem item = new SQLSelectItem(expr, alias);
if (lexer.hasComment() && lexer.isKeepComments()) {
item.addAfterComment(lexer.readAndResetComments());
}
return item;
}
Aggregations