### Question:
SqlUtils { public static SqlNodeList parseSql(String sql) throws Exception { InputStream stream = new ByteArrayInputStream(sql.getBytes()); SqlParser sqlParser = getSqlParser(stream); SqlNodeList sqlNodeList = sqlParser.parseStmtList(); return sqlNodeList; }  static SqlNodeList parseSql(String sql); static SqlParser getSqlParser(InputStream stream);  }### Answer:
@Test public void parseSqlTest() throws Exception { String table = "CREATE TABLE tbl1 (\n" + " a bigint,\n" + " h varchar, \n" + " g as 2 * (a + 1), \n" + " ts as toTimestamp(b, 'yyyy-MM-dd HH:mm:ss'), \n" + " b varchar,\n" + " proc as PROCTIME(), \n" + " PRIMARY KEY (a, b)\n" + ")\n" + "with (\n" + " 'connector' = 'kafka', \n" + " 'kafka.topic' = 'log.test'\n" + ")\n"; SqlNodeList nodeList = SqlUtils.parseSql(table); for(SqlNode sqlNode : nodeList){ Assert.assertNotNull(sqlNode); } String watermark = "CREATE TABLE tbl1 (\n" + " ts timestamp(3),\n" + " id varchar, \n" + " watermark FOR ts AS ts - interval '3' second\n" + ")\n" + " with (\n" + " 'connector' = 'kafka', \n" + " 'kafka.topic' = 'log.test'\n" + ")\n"; SqlNodeList nodeList1 = SqlUtils.parseSql(watermark); for(SqlNode sqlNode : nodeList1){ Assert.assertNotNull(sqlNode); } String fun = "create function function1 as 'org.apache.fink.function.function1' language java"; SqlNodeList nodeList2 = SqlUtils.parseSql(fun); for(SqlNode sqlNode : nodeList2){ Assert.assertNotNull(sqlNode); } String insert = "insert into emp(x,y) partition (x='ab', y='bc') select * from emp"; SqlNodeList nodeList3 = SqlUtils.parseSql(insert); for(SqlNode sqlNode : nodeList3){ Assert.assertNotNull(sqlNode); } }