odps sql parser improved comment support

This commit is contained in:
高铁
2016-01-23 17:57:51 +08:00
parent b1dd5b59af
commit 8ede2f7b73
7 changed files with 135 additions and 5 deletions
@@ -73,6 +73,10 @@ public class OdpsCreateTableParser extends SQLCreateTableParser {
} else {
accept(Token.LPAREN);
if (lexer.isKeepComments() && lexer.hasComment()) {
stmt.addBodyBeforeComment(lexer.readAndResetComments());
}
for (;;) {
if (lexer.token() != Token.IDENTIFIER) {
throw new ParserException("expect identifier");
@@ -96,6 +96,12 @@ public class OdpsOutputVisitor extends SQLASTOutputVisitor implements OdpsASTVis
int size = x.getTableElementList().size();
if (size > 0) {
print0(" (");
if (this.isPrettyFormat() && x.hasBodyBeforeComment()) {
print(' ');
printComment(x.getBodyBeforeCommentsDirect(), "");
}
incrementIndent();
println();
for (int i = 0; i < size; ++i) {