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:
@@ -108,10 +108,17 @@ public class OdpsCreateTableParser extends SQLCreateTableParser {
|
||||
SQLColumnDefinition column = this.exprParser.parseColumn();
|
||||
stmt.getPartitionColumns().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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLCaseExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLAssignItem;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLJoinTableSource.JoinType;
|
||||
@@ -93,13 +94,27 @@ public class OdpsOutputVisitor extends SQLASTOutputVisitor implements OdpsASTVis
|
||||
int partitionSize = x.getPartitionColumns().size();
|
||||
if (partitionSize > 0) {
|
||||
println();
|
||||
print("PARTITIONED (");
|
||||
print("PARTITIONED BY (");
|
||||
incrementIndent();
|
||||
println();
|
||||
for (int i = 0; i < partitionSize; ++i) {
|
||||
if (i != 0) {
|
||||
print(", ");
|
||||
SQLColumnDefinition column = x.getPartitionColumns().get(i);
|
||||
column.accept(this);
|
||||
|
||||
if (i != partitionSize - 1) {
|
||||
print(',');
|
||||
}
|
||||
if (this.isPrettyFormat() && column.hasAfterComment()) {
|
||||
print(' ');
|
||||
printComment(column.getAfterCommentsDirect(), "\n");
|
||||
}
|
||||
|
||||
if (i != partitionSize - 1) {
|
||||
println();
|
||||
}
|
||||
x.getPartitionColumns().get(i).accept(this);
|
||||
}
|
||||
decrementIndent();
|
||||
println();
|
||||
print(")");
|
||||
}
|
||||
|
||||
|
||||
@@ -989,7 +989,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Printab
|
||||
print(" COMMENT ");
|
||||
x.getComment().accept(this);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user