bug fixed for sql parser. for issue #1970

This commit is contained in:
wenshao
2017-09-14 11:07:47 +08:00
parent 98b3263363
commit ff9364cf12
3 changed files with 100 additions and 5 deletions
@@ -1745,6 +1745,13 @@ class SchemaResolveVisitorFactory {
x.setResolvedOwnerObject(parameter);
return;
}
} else if (parentCtx.object instanceof SQLMergeStatement) {
SQLMergeStatement mergeStatement = (SQLMergeStatement) parentCtx.object;
SQLTableSource into = mergeStatement.getInto();
if (into instanceof SQLSubqueryTableSource
&& into.aliasHashCode64() == owner_hash) {
x.setResolvedOwnerObject(into);
}
}
SQLDeclareItem declareItem = parentCtx.findDeclare(owner_hash);
@@ -2159,7 +2166,11 @@ class SchemaResolveVisitorFactory {
SchemaResolveVisitor.Context ctx = visitor.createContext(x);
SQLTableSource into = x.getInto();
ctx.setTableSource(into);
if (into instanceof SQLExprTableSource) {
ctx.setTableSource(into);
} else {
into.accept(visitor);
}
SQLTableSource using = x.getUsing();
if (using != null) {
@@ -2206,10 +2206,14 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
setMode(x, Mode.Merge);
String ident = x.getInto().toString();
TableStat stat = getTableStat(ident);
stat.incrementMergeCount();
SQLTableSource into = x.getInto();
if (into instanceof SQLExprTableSource) {
String ident = ((SQLExprTableSource) into).getExpr().toString();
TableStat stat = getTableStat(ident);
stat.incrementMergeCount();
} else {
into.accept(this);
}
x.getOn().accept(this);