我简单写了一下仅供参考 import org.apache.calcite.config.Lex; import org.apache.calcite.sql.SqlNode; import org.apache.calcite.sql.SqlNodeList; import org.apache.calcite.sql.parser.SqlParseException; import org.apache.calcite.sql.parser.SqlParser; import org.apache.flink.sql.parser.impl.FlinkSqlParserImpl; import org.apache.flink.sql.parser.validate.FlinkSqlConformance;
/** * @author: silence * @date: 2020/10/22 */ public class Test { public static void main(String[] args) throws SqlParseException { String sql = "xxx"; SqlParser.Config sqlParserConfig = SqlParser .configBuilder() .setParserFactory(FlinkSqlParserImpl.FACTORY) .setConformance(FlinkSqlConformance.DEFAULT) .setLex(Lex.JAVA) .setIdentifierMaxLength(256) .build(); SqlParser sqlParser = SqlParser.create(sql, sqlParserConfig); SqlNodeList sqlNodes = sqlParser.parseStmtList(); for (SqlNode sqlNode : sqlNodes) { //do something } } } -- Sent from: http://apache-flink.147419.n8.nabble.com/