Hi Liya:
Althrough that can not meet my needs,but it still helps me a lot, thank you very much for your reply. Best, Xiao. 原始邮件 发件人: Fan Liya<[email protected]> 收件人: dev<[email protected]> 发送时间: 2020年11月4日(周三) 11:35 主题: Re: How to parse sql of DDL Hi Xiao, I am not sure if we support "alter table ... add column ... after ..." statement, as some databases do not support this syntax. We do support "alter table ... add column ..." statement. An example can be found in MultiJdbcSchemaJoinTest#testSchemaConsistency, which may be helpful. Best, Liya Fan On Wed, Nov 4, 2020 at 10:53 AM xiao cai <[email protected]> wrote: > Hi Liya: > Thanks for your suggestion! > > > Here is the demo i ran using SqlParser: > > > -------------- > String sql = "ALTER TABLE `test`.`mysql_sink_test_1` ADD COLUMN > `col_for_test` varchar(255) NULL AFTER `col_binary_1`; > SqlParser.Config mysqlConfig = > SqlParser.configBuilder().setLex(Lex.MYSQL).build(); > SqlParser sqlParser = SqlParser.create(sql.toLowerCase(), mysqlConfig); > SqlNode sqlNode = sqlParser.parseStmt(); > -------------- > > > Then I received the following error message: > > > --------------------- > org.apache.calcite.sql.parser.SqlParseException: Encountered "table" at > line 1, column 7. > Was expecting one of: > "SESSION" ... > "SYSTEM" ... > at > org.apache.calcite.sql.parser.impl.SqlParserImpl.convertException(SqlParserImpl.java:364) > at > org.apache.calcite.sql.parser.impl.SqlParserImpl.normalizeException(SqlParserImpl.java:149) > at > org.apache.calcite.sql.parser.SqlParser.handleException(SqlParser.java:148) > at org.apache.calcite.sql.parser.SqlParser.parseQuery(SqlParser.java:163) > at org.apache.calcite.sql.parser.SqlParser.parseStmt(SqlParser.java:188) > ——————————— > > > > > > > 原始邮件 > 发件人: Fan Liya<[email protected]> > 收件人: dev<[email protected]> > 发送时间: 2020年11月4日(周三) 10:40 > 主题: Re: How to parse sql of DDL > > > Hi Xiao, It's hard to diagnose the problem without seeing your code. My > suggestion is that you can debug some test cases in our code base (related > to SqlParser), and check how it works. Best, Liya Fan On Wed, Nov 4, 2020 > at 10:34 AM xiao cai <[email protected]> wrote: > Hi > I just want to konw > how to parse the sql statement of DDL. I had use > SqlParser to do this, > but it was failed. > Is someone can help me , thank you very mush. > > > > Best xiao.
