mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
refactor sql parser.
This commit is contained in:
@@ -35,11 +35,9 @@ public class OdpsSelectQueryBlock extends SQLSelectQueryBlock {
|
||||
|
||||
protected List<SQLHint> hints;
|
||||
|
||||
protected List<SQLExpr> distributeBy = new ArrayList<SQLExpr>();
|
||||
protected List<SQLSelectOrderByItem> sortBy = new ArrayList<SQLSelectOrderByItem>(2);
|
||||
|
||||
public OdpsSelectQueryBlock(){
|
||||
|
||||
distributeBy = new ArrayList<SQLExpr>();
|
||||
sortBy = new ArrayList<SQLSelectOrderByItem>(2);
|
||||
}
|
||||
|
||||
public SQLOrderBy getOrderBy() {
|
||||
@@ -50,13 +48,7 @@ public class OdpsSelectQueryBlock extends SQLSelectQueryBlock {
|
||||
this.orderBy = orderBy;
|
||||
}
|
||||
|
||||
public List<SQLExpr> getDistributeBy() {
|
||||
return distributeBy;
|
||||
}
|
||||
|
||||
public List<SQLSelectOrderByItem> getSortBy() {
|
||||
return sortBy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
@@ -46,10 +46,10 @@ public class OdpsExprParser extends SQLExprParser {
|
||||
"ROW_NUMBER",
|
||||
"WM_CONCAT"//
|
||||
};
|
||||
AGGREGATE_FUNCTIONS_CODES = FnvHash.fnv_64_lower(strings, true);
|
||||
AGGREGATE_FUNCTIONS_CODES = FnvHash.fnv1a_64_lower(strings, true);
|
||||
AGGREGATE_FUNCTIONS = new String[AGGREGATE_FUNCTIONS_CODES.length];
|
||||
for (String str : strings) {
|
||||
long hash = FnvHash.fnv_64_lower(str);
|
||||
long hash = FnvHash.fnv1a_64_lower(str);
|
||||
int index = Arrays.binarySearch(AGGREGATE_FUNCTIONS_CODES, hash);
|
||||
AGGREGATE_FUNCTIONS[index] = str;
|
||||
}
|
||||
|
||||
+1
-12
@@ -64,20 +64,14 @@ public class OdpsSchemaStatVisitor extends SchemaStatVisitor implements OdpsASTV
|
||||
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();
|
||||
|
||||
TableStat stat = getTableStat(ident);
|
||||
TableStat stat = getTableStat(tableName);
|
||||
stat.incrementInsertCount();
|
||||
|
||||
Map<String, String> aliasMap = getAliasMap();
|
||||
putAliasMap(aliasMap, tableSource.getAlias(), ident);
|
||||
putAliasMap(aliasMap, ident, ident);
|
||||
}
|
||||
|
||||
for (SQLAssignItem partition : x.getPartitions()) {
|
||||
@@ -289,11 +283,6 @@ public class OdpsSchemaStatVisitor extends SchemaStatVisitor implements OdpsASTV
|
||||
|
||||
@Override
|
||||
public boolean visit(OdpsValuesTableSource x) {
|
||||
Map<String, String> aliasMap = getAliasMap();
|
||||
if (aliasMap != null && x.getAlias() != null) {
|
||||
putAliasMap(aliasMap, x.getAlias(), null);
|
||||
addSubQuery(x.getAlias(), x);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user