use of com.alibaba.druid.sql.ast.SQLExpr in project druid by alibaba.
the class OdpsSchemaStatVisitor method visit.
@Override
public boolean visit(OdpsInsert x) {
setMode(x, TableStat.Mode.Insert);
setAliasMap();
SQLExprTableSource tableSource = x.getTableSource();
SQLExpr tableName = tableSource.getExpr();
if (tableName instanceof SQLName) {
String ident = ((SQLName) tableName).toString();
setCurrentTable(ident);
TableStat stat = getTableStat(ident);
stat.incrementInsertCount();
Map<String, String> aliasMap = getAliasMap();
putAliasMap(aliasMap, tableSource.getAlias(), ident);
putAliasMap(aliasMap, ident, ident);
}
for (SQLAssignItem partition : x.getPartitions()) {
partition.accept(this);
}
accept(x.getQuery());
return false;
}
use of com.alibaba.druid.sql.ast.SQLExpr in project druid by alibaba.
the class MySqlOutputVisitor method visit.
@Override
public boolean visit(MySqlAlterUserStatement x) {
print0(ucase ? "ALTER USER" : "alter user");
for (SQLExpr user : x.getUsers()) {
print(' ');
user.accept(this);
print0(ucase ? " PASSWORD EXPIRE" : " password expire");
}
return false;
}
use of com.alibaba.druid.sql.ast.SQLExpr in project druid by alibaba.
the class PhoenixStatementParser method parseInsertColumns.
@Override
protected void parseInsertColumns(SQLInsertInto insert) {
if (lexer.token() == Token.RPAREN) {
return;
}
for (; ; ) {
SQLName expr = this.exprParser.name();
expr.setParent(insert);
insert.getColumns().add(expr);
if (lexer.token() == Token.IDENTIFIER) {
String text = lexer.stringVal();
if (text.equalsIgnoreCase("TINYINT") || text.equalsIgnoreCase("BIGINT") || text.equalsIgnoreCase("INTEGER") || text.equalsIgnoreCase("DOUBLE") || text.equalsIgnoreCase("DATE") || text.equalsIgnoreCase("VARCHAR")) {
expr.getAttributes().put("dataType", text);
lexer.nextToken();
} else if (text.equalsIgnoreCase("CHAR")) {
String dataType = text;
lexer.nextToken();
accept(Token.LPAREN);
SQLExpr char_len = this.exprParser.primary();
accept(Token.RPAREN);
dataType += ("(" + char_len.toString() + ")");
expr.getAttributes().put("dataType", dataType);
}
}
if (lexer.token() == Token.COMMA) {
lexer.nextToken();
continue;
}
break;
}
}
use of com.alibaba.druid.sql.ast.SQLExpr in project druid by alibaba.
the class PGExprParser method primary.
public SQLExpr primary() {
if (lexer.token() == Token.ARRAY) {
SQLArrayExpr array = new SQLArrayExpr();
array.setExpr(new SQLIdentifierExpr(lexer.stringVal()));
lexer.nextToken();
accept(Token.LBRACKET);
this.exprList(array.getValues(), array);
accept(Token.RBRACKET);
return primaryRest(array);
} else if (lexer.token() == Token.POUND) {
lexer.nextToken();
if (lexer.token() == Token.LBRACE) {
lexer.nextToken();
String varName = lexer.stringVal();
lexer.nextToken();
accept(Token.RBRACE);
SQLVariantRefExpr expr = new SQLVariantRefExpr("#{" + varName + "}");
return primaryRest(expr);
} else {
SQLExpr value = this.primary();
SQLUnaryExpr expr = new SQLUnaryExpr(SQLUnaryOperator.Pound, value);
return primaryRest(expr);
}
}
return super.primary();
}
use of com.alibaba.druid.sql.ast.SQLExpr in project druid by alibaba.
the class PGSQLStatementParser method parseAlterColumn.
protected SQLAlterTableAlterColumn parseAlterColumn() {
if (lexer.token() == Token.COLUMN) {
lexer.nextToken();
}
SQLColumnDefinition column = this.exprParser.parseColumn();
SQLAlterTableAlterColumn alterColumn = new SQLAlterTableAlterColumn();
alterColumn.setColumn(column);
if (column.getDataType() == null && column.getConstraints().size() == 0) {
if (lexer.token() == Token.SET) {
lexer.nextToken();
if (lexer.token() == Token.NOT) {
lexer.nextToken();
accept(Token.NULL);
alterColumn.setSetNotNull(true);
} else {
accept(Token.DEFAULT);
SQLExpr defaultValue = this.exprParser.expr();
alterColumn.setSetDefault(defaultValue);
}
} else if (lexer.token() == Token.DROP) {
lexer.nextToken();
if (lexer.token() == Token.NOT) {
lexer.nextToken();
accept(Token.NULL);
alterColumn.setDropNotNull(true);
} else {
accept(Token.DEFAULT);
alterColumn.setDropDefault(true);
}
}
}
return alterColumn;
}
Aggregations