tristaZero opened a new issue #7894:
URL: https://github.com/apache/shardingsphere/issues/7894


   This feature is to format the inputted SQL. Here is a example.
   
   The inputted SQL is
   ```sql
   select id,     name,        code from users where         id=1 and 
name=(select name from teachers where    id=2);
   ```
   
   The output SQL could be
   ```sql
   select id,  name, code 
   from users 
   where id=1 
   and 
   name = (
   select name 
   from teachers 
   where id=2);
   ```
   
   Hey, the case above is just an example, which means the output SQL may be 
different, but the mechanisms are the same!
   
   The programming entrance of this feature basically finished, please refer to,
   ```java
           String formatResult =
                   (String) SQLVisitorFactory.newInstance(databaseTypeName, 
SQLVisitorType.FORMAT, 
SQLVisitorRule.valueOf(parseTree.getClass())).visit(parseTree);
   
   // As you know the visitor factory looks familiar with the following one in 
`StandardSQLParserEngine.JAVA`
   SQLStatement result =
                   (SQLStatement) 
SQLVisitorFactory.newInstance(databaseTypeName, SQLVisitorType.STATEMENT, 
SQLVisitorRule.valueOf(parseTree.getClass())).visit(parseTree);
   ```
   What's more, `MySQLFormatSQLVisitorFacade` is prepared for your endeavor and 
enthusiasm!


----------------------------------------------------------------
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]


Reply via email to