bug fixed for sql parser.

This commit is contained in:
wenshao
2017-07-06 03:07:35 +08:00
parent 717726badd
commit 1e0ce32284
33 changed files with 744 additions and 142 deletions
@@ -36,12 +36,22 @@ import java.util.concurrent.ConcurrentSkipListMap;
* Created by wenshao on 03/06/2017.
*/
public class SchemaRepository {
private String name;
private final Map<String, SchemaObject> objects = new ConcurrentSkipListMap<String, SchemaObject>();
private final Map<String, SchemaObject> functions = new ConcurrentSkipListMap<String, SchemaObject>();
private final SchemaVisitor visitor = new SchemaVisitor();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public SchemaObject findTable(String tableName) {
String lowerName = tableName.toLowerCase();
SchemaObject object = objects.get(lowerName);
@@ -144,6 +154,16 @@ public class SchemaRepository {
}
return tableObject;
}
if (expr instanceof SQLPropertyExpr) {
String tableName = ((SQLPropertyExpr) expr).getName();
tableObject = findTable(tableName);
if (tableObject != null) {
exprTableSource.setSchemaObject(tableObject);
}
return tableObject;
}
}
return null;
}
@@ -222,6 +242,16 @@ public class SchemaRepository {
if (tableSource instanceof SQLExprTableSource) {
return findTable(tableSource, tableSource.computeAlias());
}
if (tableSource instanceof SQLJoinTableSource) {
SQLJoinTableSource join = (SQLJoinTableSource) tableSource;
SchemaObject table = findTable(join.getLeft(), expr);
if (table == null) {
table = findTable(join.getRight(), expr);
}
return table;
}
return null;
}