improved sql parser.

This commit is contained in:
wenshao
2017-08-29 21:15:09 +08:00
parent 718500cf59
commit fd20785f6b
48 changed files with 894 additions and 847 deletions
@@ -24,7 +24,6 @@ import com.alibaba.druid.sql.ast.statement.SQLTableSource;
import com.alibaba.druid.sql.ast.statement.SQLTableSourceImpl;
import com.alibaba.druid.sql.dialect.odps.visitor.OdpsASTVisitor;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import com.alibaba.druid.util.FNVUtils;
public class OdpsLateralViewTableSource extends SQLTableSourceImpl {
@@ -79,13 +78,13 @@ public class OdpsLateralViewTableSource extends SQLTableSourceImpl {
}
public SQLTableSource findTableSource(long alias_hash) {
long hash = this.alias_hash();
long hash = this.aliasHashCode64();
if (hash != 0 && hash == alias_hash) {
return this;
}
for (SQLName column : columns) {
if (column.name_hash_lower() == alias_hash) {
if (column.nameHashCode64() == alias_hash) {
return this;
}
}
@@ -99,7 +98,7 @@ public class OdpsLateralViewTableSource extends SQLTableSourceImpl {
public SQLTableSource findTableSourceWithColumn(long columnNameHash) {
for (SQLName column : columns) {
if (column.name_hash_lower() == columnNameHash) {
if (column.nameHashCode64() == columnNameHash) {
return this;
}
}
@@ -24,7 +24,7 @@ import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
import com.alibaba.druid.sql.ast.statement.SQLSelectItem;
import com.alibaba.druid.sql.dialect.odps.ast.OdpsUDTFSQLSelectItem;
import com.alibaba.druid.sql.parser.*;
import com.alibaba.druid.util.FNVUtils;
import com.alibaba.druid.util.FnvHash;
import com.alibaba.druid.util.JdbcConstants;
import java.util.Arrays;
@@ -46,10 +46,10 @@ public class OdpsExprParser extends SQLExprParser {
"ROW_NUMBER",
"WM_CONCAT"//
};
AGGREGATE_FUNCTIONS_CODES = FNVUtils.fnv_64_lower(strings, true);
AGGREGATE_FUNCTIONS_CODES = FnvHash.fnv_64_lower(strings, true);
AGGREGATE_FUNCTIONS = new String[AGGREGATE_FUNCTIONS_CODES.length];
for (String str : strings) {
long hash = FNVUtils.fnv_64_lower(str);
long hash = FnvHash.fnv_64_lower(str);
int index = Arrays.binarySearch(AGGREGATE_FUNCTIONS_CODES, hash);
AGGREGATE_FUNCTIONS[index] = str;
}