improved sql parser, support apache phoenix.

This commit is contained in:
wenshao
2016-09-14 15:05:12 +08:00
parent 49d7884c96
commit 77ee426082
33 changed files with 717 additions and 359 deletions
@@ -0,0 +1,118 @@
package com.alibaba.druid.sql.ast.statement;
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.SQLStatementImpl;
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
/**
* Created by wenshao on 16/9/14.
*/
public class SQLCreateSequenceStatement extends SQLStatementImpl {
private SQLName name;
private SQLExpr startWith;
private SQLExpr incrementBy;
private SQLExpr minValue;
private SQLExpr maxValue;
private boolean noMaxValue;
private boolean noMinValue;
private Boolean cycle;
private Boolean cache;
private Boolean order;
@Override
public void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
acceptChild(visitor, name);
acceptChild(visitor, startWith);
acceptChild(visitor, incrementBy);
acceptChild(visitor, minValue);
acceptChild(visitor, maxValue);
}
visitor.endVisit(this);
}
public SQLName getName() {
return name;
}
public void setName(SQLName name) {
this.name = name;
}
public SQLExpr getStartWith() {
return startWith;
}
public void setStartWith(SQLExpr startWith) {
this.startWith = startWith;
}
public SQLExpr getIncrementBy() {
return incrementBy;
}
public void setIncrementBy(SQLExpr incrementBy) {
this.incrementBy = incrementBy;
}
public SQLExpr getMaxValue() {
return maxValue;
}
public void setMaxValue(SQLExpr maxValue) {
this.maxValue = maxValue;
}
public Boolean getCycle() {
return cycle;
}
public void setCycle(Boolean cycle) {
this.cycle = cycle;
}
public Boolean getCache() {
return cache;
}
public void setCache(Boolean cache) {
this.cache = cache;
}
public Boolean getOrder() {
return order;
}
public void setOrder(Boolean order) {
this.order = order;
}
public SQLExpr getMinValue() {
return minValue;
}
public void setMinValue(SQLExpr minValue) {
this.minValue = minValue;
}
public boolean isNoMaxValue() {
return noMaxValue;
}
public void setNoMaxValue(boolean noMaxValue) {
this.noMaxValue = noMaxValue;
}
public boolean isNoMinValue() {
return noMinValue;
}
public void setNoMinValue(boolean noMinValue) {
this.noMinValue = noMinValue;
}
}
@@ -26,6 +26,8 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLInsertStatement extends SQLInsertInto implements SQLStatement {
private String dbType;
protected boolean upsert = false; // for phoenix
public SQLInsertStatement(){
}
@@ -42,6 +44,14 @@ public class SQLInsertStatement extends SQLInsertInto implements SQLStatement {
visitor.endVisit(this);
}
public boolean isUpsert() {
return upsert;
}
public void setUpsert(boolean upsert) {
this.upsert = upsert;
}
public static class ValuesClause extends SQLObjectImpl {
private final List<SQLExpr> values;