tristaZero commented on a change in pull request #8575:
URL: https://github.com/apache/shardingsphere/pull/8575#discussion_r540668956
##########
File path: docs/document/content/features/sharding/principle/parse.cn.md
##########
@@ -103,3 +103,108 @@ SQLVisitorEngine sqlVisitorEngine = new
SQLVisitorEngine(databaseType, "STATEMEN
SQLStatement sqlStatement = sqlVisitorEngine.visit(tree);
```
+
+- SQL格式化
+
+```
+/**
+ * databaseType type:String 可能值 MySQL
+ * useCache type:boolean 是否使用缓存
+ * @return String
+ */
+ParseTree tree = new SQLParserEngine(databaseType).parse(sql, useCache);
+SQLVisitorEngine sqlVisitorEngine = new SQLVisitorEngine(databaseType,
"FORMAT");
+String formatedSql = sqlVisitorEngine.visit(tree);
+
+//例子
+sql1 : select a+1 as b, name n from table1 join table2 where id=1 and
name='lu';
+sql2 : select id, name, age, sex, ss, yy from table1 where id=1;
+sql3 : select id, name, age, count(*) as n, (select id, name, age, sex from
table2 where id=2) as sid, yyyy from table1 where id=1;
Review comment:
Could you put these SQL cases and their formatted result into a table?
For example, one row of a table contains one SQL column and its formatted
output in another column. Therefore users can get a quick comparison, I guess.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]