smm321 opened a new issue, #193:
URL: https://github.com/apache/paimon-webui/issues/193

   ### Search before asking
   
   - [X] I searched in the 
[issues](https://github.com/apache/paimon-webui/issues) and found nothing 
similar.
   
   
   ### Paimon UI version
   
   main
   
   ### Compute Engine
   
   Flink
   
   ### Minimal reproduce step
   
   Currently,`org.apache.paimon.web.engine.flink.common.parser.StatementParser` 
processes input strings in a 'split line Separator' way. It can't handle the 
statements which contain a line separator itself.
   
   ### What doesn't meet your expectations?
   
   In my option, a more graceful way to solve this issue is that we create a 
Calcite Sql Parser with a FlinkSqlParser Factory.
   
   ```
   /**
    * CustomSqlParser to parse Sql list.
    */
   public class CustomSqlParser {
   
       private static final SqlParser.Config config;
       private SqlParser parser;
       static {
           config = SqlParser.configBuilder()
                   .setParserFactory(FlinkSqlParserImpl.FACTORY)
                   .setConformance(FlinkSqlConformance.DEFAULT)
                   .setLex(Lex.JAVA)
                   .setIdentifierMaxLength(256)
                   .build();
       }
   
       public CustomSqlParser(String sql){
           parser = SqlParser.create(sql, config);
       }
   
       public SqlParser getParser(){
           return parser;
       }
   }
   ```
   
   Then sqlParser can parse kinds of statements and return a sqlNodeList. The 
last thing we need to do is get the sqlKind of every sqlNode such as 
   ```
   CustomSqlParser customSqlParser = new CustomSqlParser(statementSetString);
   SqlNodeList sqlNodeList = customSqlParser.getParser().parseStmtList();
   for (SqlNode sqlNode : sqlNodeList) {
        System.out.println(sqlNode.getKind());
   }
   ```
   We just use AST level of Apache Calcite that do not need to validate if the 
tables or columns are legal or not
   
   ### Anything else?
   
   no
   
   ### Are you willing to submit a PR?
   
   - [X] I'm willing to submit a PR!


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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to