improved sql parser, support over winding_clause.

This commit is contained in:
wenshao
2016-10-09 13:28:58 +08:00
parent 57bf786427
commit 27e6b8f9f4
5 changed files with 211 additions and 9 deletions
@@ -1760,7 +1760,8 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
print0(ucase ? " RANGE " : " range ");
}
x.getWindowing().accept(this);
printWindowingExpr(x.getWindowing());
if (x.isWindowingPreceding()) {
print0(ucase ? " PRECEDING" : " preceding");
} else if (x.isWindowingFollowing()) {
@@ -1775,7 +1776,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
print0(ucase ? " RANGE BETWEEN " : " range between ");
}
x.getWindowingBetweenBegin().accept(this);
printWindowingExpr(x.getWindowingBetweenBegin());
if (x.isWindowingBetweenBeginPreceding()) {
print0(ucase ? " PRECEDING" : " preceding");
@@ -1785,7 +1786,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
print0(ucase ? " AND " : " and ");
x.getWindowingBetweenEnd().accept(this);
printWindowingExpr(x.getWindowingBetweenEnd());
if (x.isWindowingBetweenEndPreceding()) {
print0(ucase ? " PRECEDING" : " preceding");
@@ -1797,6 +1798,15 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
print(')');
return false;
}
void printWindowingExpr(SQLExpr expr) {
if (expr instanceof SQLIdentifierExpr) {
String ident = ((SQLIdentifierExpr) expr).getName();
print0(ucase ? ident : ident.toLowerCase());
} else {
expr.accept(this);
}
}
@Override
public boolean visit(SQLKeep x) {