You might have a look at how we're adding DDL to Hazelcast Jet: https://github.com/hazelcast/hazelcast-jet/pull/2620
Have a look at the `parserImpls.ftl` file. Viliam On Wed, 4 Nov 2020 at 09:24, xiao cai <[email protected]> wrote: > 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. -- Viliam Durina Jet Developer hazelcast® <https://www.hazelcast.com> 2 W 5th Ave, Ste 300 | San Mateo, CA 94402 | USA +1 (650) 521-5453 | hazelcast.com <https://www.hazelcast.com> -- This message contains confidential information and is intended only for the individuals named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. If verification is required, please request a hard-copy version. -Hazelcast
