mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved sql parser phoenix support.
This commit is contained in:
+44
@@ -15,7 +15,10 @@
|
||||
*/
|
||||
package com.alibaba.druid.sql.dialect.phoenix.parser;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.SQLName;
|
||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLInsertInto;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLInsertStatement;
|
||||
import com.alibaba.druid.sql.parser.Lexer;
|
||||
import com.alibaba.druid.sql.parser.ParserException;
|
||||
@@ -33,4 +36,45 @@ public class PhoenixStatementParser extends SQLStatementParser {
|
||||
public PhoenixStatementParser(Lexer lexer){
|
||||
super(new PhoenixExprParser(lexer));
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user