mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed for odps sql formatter
This commit is contained in:
@@ -81,10 +81,18 @@ public class OdpsCreateTableParser extends SQLCreateTableParser {
|
||||
SQLColumnDefinition column = this.exprParser.parseColumn();
|
||||
stmt.getTableElementList().add(column);
|
||||
|
||||
if (lexer.isKeepComments() && lexer.hasComment()) {
|
||||
column.addAfterComment(lexer.readAndResetComments());
|
||||
}
|
||||
|
||||
if (!(lexer.token() == (Token.COMMA))) {
|
||||
break;
|
||||
} else {
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.isKeepComments() && lexer.hasComment()) {
|
||||
column.addAfterComment(lexer.readAndResetComments());
|
||||
}
|
||||
}
|
||||
}
|
||||
accept(Token.RPAREN);
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource.JoinType;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectGroupByClause;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectItem;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLTableElement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsAddStatisticStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsAnalyzeTableStatement;
|
||||
import com.alibaba.druid.sql.dialect.odps.ast.OdpsCreateTableStatement;
|
||||
@@ -74,11 +75,20 @@ public class OdpsOutputVisitor extends SQLASTOutputVisitor implements OdpsASTVis
|
||||
incrementIndent();
|
||||
println();
|
||||
for (int i = 0; i < size; ++i) {
|
||||
if (i != 0) {
|
||||
print(", ");
|
||||
SQLTableElement element = x.getTableElementList().get(i);
|
||||
element.accept(this);
|
||||
|
||||
if (i != size - 1) {
|
||||
print(',');
|
||||
}
|
||||
if (this.isPrettyFormat() && element.hasAfterComment()) {
|
||||
print(' ');
|
||||
printComment(element.getAfterCommentsDirect(), "\n");
|
||||
}
|
||||
|
||||
if (i != size - 1) {
|
||||
println();
|
||||
}
|
||||
x.getTableElementList().get(i).accept(this);
|
||||
}
|
||||
decrementIndent();
|
||||
println();
|
||||
|
||||
Reference in New Issue
Block a user