apache / shardingsphere

Empowering Data Intelligence with Distributed SQL for Sharding, Scalability, and Security Across All Databases.
Apache License 2.0
19.94k stars 6.74k forks source link

Got a NullPointerException when parsing a simple mysql sql statement #8589

Closed springnick closed 3 years ago

springnick commented 3 years ago

Bug Report

For English only, other languages will not accept.

Before report a bug, make sure you have:

Please pay attention on issues you submitted, because we maybe need more details. If no response anymore and we cannot reproduce it on current information, we will close it.

Please answer these questions before submitting your issue. Thanks!

Which version of ShardingSphere did you use?

A: 4.1.1

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

A: ShardingSphere-JDBC

Expected behavior

A: sql should be able to be parsed correctly,

Actual behavior

A: got an exception when parsing a simple sql

Reason analyze (If you can)

A: not sure, please check the exception message

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

A: with ShardingSphere 4.1.1, write a simple junit test case to parse a simple sql as following: public class ParserTest {

@Test
public void testParse(){
    SQLParserEngine parserEngine= SQLParserEngineFactory.getSQLParserEngine("MySQL");
    String sql="select user_id, name, profile from t_user where name=?";
    SQLStatement sqlStatement=parserEngine.parse(sql,false);
    Assert.notNull(sqlStatement,"statement should not be null");
}

}

///////////////////////////////////////////////////////// Exception message ///////

/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/bin/java -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=58440:/Applications/IntelliJ IDEA.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit-rt.jar:/Applications/IntelliJ IDEA.app/Contents/plugins/junit/lib/junit5-rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/lib/packager.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/lib/tools.jar:/Users/nick/Desktop/spring/nick1/target/test-classes:/Users/nick/Desktop/spring/nick1/target/classes:/Users/nick/.m2/repository/com/nick/template/1.0-SNAPSHOT/template-1.0-SNAPSHOT.jar:/Users/nick/.m2/repository/org/springframework/boot/spring-boot-starter/1.5.2.RELEASE/spring-boot-starter-1.5.2.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/boot/spring-boot/1.5.2.RELEASE/spring-boot-1.5.2.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.5.2.RELEASE/spring-boot-autoconfigure-1.5.2.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.5.2.RELEASE/spring-boot-starter-logging-1.5.2.RELEASE.jar:/Users/nick/.m2/repository/ch/qos/logback/logback-classic/1.1.11/logback-classic-1.1.11.jar:/Users/nick/.m2/repository/ch/qos/logback/logback-core/1.1.11/logback-core-1.1.11.jar:/Users/nick/.m2/repository/org/slf4j/jul-to-slf4j/1.7.24/jul-to-slf4j-1.7.24.jar:/Users/nick/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.24/log4j-over-slf4j-1.7.24.jar:/Users/nick/.m2/repository/org/yaml/snakeyaml/1.17/snakeyaml-1.17.jar:/Users/nick/.m2/repository/org/springframework/boot/spring-boot-starter-data-jpa/1.5.2.RELEASE/spring-boot-starter-data-jpa-1.5.2.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/boot/spring-boot-starter-aop/1.5.2.RELEASE/spring-boot-starter-aop-1.5.2.RELEASE.jar:/Users/nick/.m2/repository/org/aspectj/aspectjweaver/1.8.9/aspectjweaver-1.8.9.jar:/Users/nick/.m2/repository/org/hibernate/hibernate-core/5.0.12.Final/hibernate-core-5.0.12.Final.jar:/Users/nick/.m2/repository/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar:/Users/nick/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar:/Users/nick/.m2/repository/org/javassist/javassist/3.21.0-GA/javassist-3.21.0-GA.jar:/Users/nick/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar:/Users/nick/.m2/repository/org/jboss/jandex/2.0.0.Final/jandex-2.0.0.Final.jar:/Users/nick/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar:/Users/nick/.m2/repository/org/hibernate/common/hibernate-commons-annotations/5.0.1.Final/hibernate-commons-annotations-5.0.1.Final.jar:/Users/nick/.m2/repository/org/hibernate/hibernate-entitymanager/5.0.12.Final/hibernate-entitymanager-5.0.12.Final.jar:/Users/nick/.m2/repository/javax/transaction/javax.transaction-api/1.2/javax.transaction-api-1.2.jar:/Users/nick/.m2/repository/org/springframework/data/spring-data-jpa/1.11.1.RELEASE/spring-data-jpa-1.11.1.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/data/spring-data-commons/1.13.1.RELEASE/spring-data-commons-1.13.1.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/spring-orm/4.3.7.RELEASE/spring-orm-4.3.7.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/spring-context/4.3.7.RELEASE/spring-context-4.3.7.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/spring-tx/4.3.7.RELEASE/spring-tx-4.3.7.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/spring-beans/4.3.7.RELEASE/spring-beans-4.3.7.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/spring-aspects/4.3.7.RELEASE/spring-aspects-4.3.7.RELEASE.jar:/Users/nick/.m2/repository/org/mybatis/spring/boot/mybatis-spring-boot-starter/2.1.4/mybatis-spring-boot-starter-2.1.4.jar:/Users/nick/.m2/repository/org/mybatis/spring/boot/mybatis-spring-boot-autoconfigure/2.1.4/mybatis-spring-boot-autoconfigure-2.1.4.jar:/Users/nick/.m2/repository/org/mybatis/mybatis/3.5.6/mybatis-3.5.6.jar:/Users/nick/.m2/repository/org/mybatis/mybatis-spring/2.0.6/mybatis-spring-2.0.6.jar:/Users/nick/.m2/repository/org/springframework/boot/spring-boot-starter-security/1.5.2.RELEASE/spring-boot-starter-security-1.5.2.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/spring-aop/4.3.7.RELEASE/spring-aop-4.3.7.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/security/spring-security-config/4.2.2.RELEASE/spring-security-config-4.2.2.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/security/spring-security-web/4.2.2.RELEASE/spring-security-web-4.2.2.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/spring-expression/4.3.7.RELEASE/spring-expression-4.3.7.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.5.2.RELEASE/spring-boot-starter-web-1.5.2.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.5.2.RELEASE/spring-boot-starter-tomcat-1.5.2.RELEASE.jar:/Users/nick/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.11/tomcat-embed-core-8.5.11.jar:/Users/nick/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.5.11/tomcat-embed-el-8.5.11.jar:/Users/nick/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/8.5.11/tomcat-embed-websocket-8.5.11.jar:/Users/nick/.m2/repository/org/hibernate/hibernate-validator/5.3.4.Final/hibernate-validator-5.3.4.Final.jar:/Users/nick/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar:/Users/nick/.m2/repository/com/fasterxml/classmate/1.3.3/classmate-1.3.3.jar:/Users/nick/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.8.7/jackson-databind-2.8.7.jar:/Users/nick/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.8.0/jackson-annotations-2.8.0.jar:/Users/nick/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.8.7/jackson-core-2.8.7.jar:/Users/nick/.m2/repository/org/springframework/spring-web/4.3.7.RELEASE/spring-web-4.3.7.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/spring-webmvc/4.3.7.RELEASE/spring-webmvc-4.3.7.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/boot/spring-boot-starter-jdbc/1.5.2.RELEASE/spring-boot-starter-jdbc-1.5.2.RELEASE.jar:/Users/nick/.m2/repository/org/apache/tomcat/tomcat-jdbc/8.5.11/tomcat-jdbc-8.5.11.jar:/Users/nick/.m2/repository/org/apache/tomcat/tomcat-juli/8.5.11/tomcat-juli-8.5.11.jar:/Users/nick/.m2/repository/org/springframework/spring-jdbc/4.3.7.RELEASE/spring-jdbc-4.3.7.RELEASE.jar:/Users/nick/.m2/repository/mysql/mysql-connector-java/8.0.20/mysql-connector-java-8.0.20.jar:/Users/nick/.m2/repository/com/google/protobuf/protobuf-java/3.6.1/protobuf-java-3.6.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/sharding-jdbc-spring-boot-starter/4.1.1/sharding-jdbc-spring-boot-starter-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/sharding-spring-boot-util/4.1.1/sharding-spring-boot-util-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/sharding-core-common/4.1.1/sharding-core-common-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/shardingsphere-common/4.1.1/shardingsphere-common-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/shardingsphere-spi/4.1.1/shardingsphere-spi-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/shardingsphere-sql-parser-binder/4.1.1/shardingsphere-sql-parser-binder-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/sharding-core-api/4.1.1/sharding-core-api-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/encrypt-core-api/4.1.1/encrypt-core-api-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/encrypt-core-common/4.1.1/encrypt-core-common-4.1.1.jar:/Users/nick/.m2/repository/org/codehaus/groovy/groovy/2.4.5/groovy-2.4.5-indy.jar:/Users/nick/.m2/repository/commons-codec/commons-codec/1.10/commons-codec-1.10.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/sharding-transaction-spring/4.1.1/sharding-transaction-spring-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/sharding-transaction-core/4.1.1/sharding-transaction-core-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/sharding-jdbc-core/4.1.1/sharding-jdbc-core-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/shardingsphere-pluggable/4.1.1/shardingsphere-pluggable-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/shardingsphere-route/4.1.1/shardingsphere-route-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/shardingsphere-rewrite-engine/4.1.1/shardingsphere-rewrite-engine-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/shardingsphere-executor/4.1.1/shardingsphere-executor-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/shardingsphere-merge/4.1.1/shardingsphere-merge-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/shardingsphere-sql-parser-sql92/4.1.1/shardingsphere-sql-parser-sql92-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/shardingsphere-sql-parser-engine/4.1.1/shardingsphere-sql-parser-engine-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/shardingsphere-sql-parser-spi/4.1.1/shardingsphere-sql-parser-spi-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/shardingsphere-sql-parser-statement/4.1.1/shardingsphere-sql-parser-statement-4.1.1.jar:/Users/nick/.m2/repository/org/apache/commons/commons-collections4/4.2/commons-collections4-4.2.jar:/Users/nick/.m2/repository/org/antlr/antlr4-runtime/4.7.2/antlr4-runtime-4.7.2.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/shardingsphere-sql-parser-mysql/4.1.1/shardingsphere-sql-parser-mysql-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/shardingsphere-sql-parser-postgresql/4.1.1/shardingsphere-sql-parser-postgresql-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/shardingsphere-sql-parser-oracle/4.1.1/shardingsphere-sql-parser-oracle-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/shardingsphere-sql-parser-sqlserver/4.1.1/shardingsphere-sql-parser-sqlserver-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/sharding-core-route/4.1.1/sharding-core-route-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/master-slave-core-route/4.1.1/master-slave-core-route-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/sharding-core-rewrite/4.1.1/sharding-core-rewrite-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/encrypt-core-rewrite/4.1.1/encrypt-core-rewrite-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/shadow-core-rewrite/4.1.1/shadow-core-rewrite-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/sharding-core-execute/4.1.1/sharding-core-execute-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/sharding-core-merge/4.1.1/sharding-core-merge-4.1.1.jar:/Users/nick/.m2/repository/org/apache/shardingsphere/encrypt-core-merge/4.1.1/encrypt-core-merge-4.1.1.jar:/Users/nick/.m2/repository/com/google/guava/guava/18.0/guava-18.0.jar:/Users/nick/.m2/repository/org/slf4j/slf4j-api/1.7.24/slf4j-api-1.7.24.jar:/Users/nick/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.24/jcl-over-slf4j-1.7.24.jar:/Users/nick/.m2/repository/com/baomidou/dynamic-datasource-spring-boot-starter/3.2.1/dynamic-datasource-spring-boot-starter-3.2.1.jar:/Users/nick/.m2/repository/org/springframework/boot/spring-boot-starter-test/1.5.2.RELEASE/spring-boot-starter-test-1.5.2.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/boot/spring-boot-test/1.5.2.RELEASE/spring-boot-test-1.5.2.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/boot/spring-boot-test-autoconfigure/1.5.2.RELEASE/spring-boot-test-autoconfigure-1.5.2.RELEASE.jar:/Users/nick/.m2/repository/com/jayway/jsonpath/json-path/2.2.0/json-path-2.2.0.jar:/Users/nick/.m2/repository/net/minidev/json-smart/2.2.1/json-smart-2.2.1.jar:/Users/nick/.m2/repository/net/minidev/accessors-smart/1.1/accessors-smart-1.1.jar:/Users/nick/.m2/repository/org/ow2/asm/asm/5.0.3/asm-5.0.3.jar:/Users/nick/.m2/repository/junit/junit/4.12/junit-4.12.jar:/Users/nick/.m2/repository/org/assertj/assertj-core/2.6.0/assertj-core-2.6.0.jar:/Users/nick/.m2/repository/org/mockito/mockito-core/1.10.19/mockito-core-1.10.19.jar:/Users/nick/.m2/repository/org/objenesis/objenesis/2.1/objenesis-2.1.jar:/Users/nick/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/Users/nick/.m2/repository/org/hamcrest/hamcrest-library/1.3/hamcrest-library-1.3.jar:/Users/nick/.m2/repository/org/skyscreamer/jsonassert/1.4.0/jsonassert-1.4.0.jar:/Users/nick/.m2/repository/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar:/Users/nick/.m2/repository/org/springframework/spring-core/4.3.7.RELEASE/spring-core-4.3.7.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/spring-test/4.3.7.RELEASE/spring-test-4.3.7.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/security/spring-security-test/4.2.2.RELEASE/spring-security-test-4.2.2.RELEASE.jar:/Users/nick/.m2/repository/org/springframework/security/spring-security-core/4.2.2.RELEASE/spring-security-core-4.2.2.RELEASE.jar:/Users/nick/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 com.example.nick1.ParserTest,testParse line 1:22 no viable alternative at input 'profile' line 1:22 mismatched input 'profile' expecting {'!', '~', '+', '-', '.', '(', '{', '?', '@', TRUNCATE, POSITION, VIEW, VALUES, CASE, CAST, TRIM, SUBSTRING, LEFT, RIGHT, IF, NOT, NULL, TRUE, FALSE, EXISTS, ANY, OFFSET, BEGIN, COMMIT, ROLLBACK, SAVEPOINT, BOOLEAN, CHAR, INTERVAL, DATE, TIME, TIMESTAMP, LOCALTIME, LOCALTIMESTAMP, YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND, MICROSECOND, MAX, MIN, SUM, COUNT, AVG, CURRENT, ENABLE, DISABLE, INSTANCE, DO, DEFINER, CASCADED, LOCAL, CLOSE, OPEN, NEXT, NAME, TYPE, DATABASE, TABLES, TABLESPACE, COLUMNS, FIELDS, INDEXES, STATUS, REPLACE, MODIFY, VALUE, DUPLICATE, FIRST, LAST, AFTER, OJ, MOD, ACCOUNT, USER, ROLE, START, TRANSACTION, ROW, WITHOUT, BINARY, ESCAPE, SUBPARTITION, STORAGE, SUPER, SUBSTR, TEMPORARY, THAN, UNBOUNDED, SIGNED, UPGRADE, VALIDATION, ROLLUP, SOUNDS, UNKNOWN, OFF, ALWAYS, COMMITTED, LEVEL, NO, PASSWORD, PRIVILEGES, ACTION, ALGORITHM, AUTOCOMMIT, BTREE, CHAIN, CHARSET, CHECKSUM, CIPHER, CLIENT, COALESCE, COMMENT, COMPACT, COMPRESSED, COMPRESSION, CONNECTION, CONSISTENT, CONVERT, DATA, DISCARD, DISK, ENCRYPTION, END, ENGINE, EVENT, EXCHANGE, EXECUTE, EXTRACT, FILE, FIXED, FOLLOWING, GLOBAL, HASH, IMPORT_, LESS, MATCH, MEMORY, NONE, NOW, PARSER, PARTIAL, PARTITIONING, PERSIST, PRECEDING, PROCESS, PROXY, QUICK, REBUILD, REDUNDANT, RELOAD, REMOVE, REORGANIZE, REPAIR, REVERSE, SESSION, SHUTDOWN, SIMPLE, SLAVE, VISIBLE, INVISIBLE, ENFORCED, AGAINST, LANGUAGE, MODE, QUERY, EXTENDED, EXPANSION, VARIANCE, MAX_ROWS, MIN_ROWS, SQL_BIG_RESULT, SQL_BUFFER_RESULT, SQL_CACHE, SQL_NO_CACHE, STATS_AUTO_RECALC, STATS_PERSISTENT, STATS_SAMPLE_PAGES, ROW_FORMAT, WEIGHT_STRING, COLUMN_FORMAT, INSERT_METHOD, KEY_BLOCK_SIZE, PACK_KEYS, PERSIST_ONLY, BIT_AND, BIT_OR, BIT_XOR, GROUP_CONCAT, JSON_ARRAYAGG, JSON_OBJECTAGG, STD, STDDEV, STDDEV_POP, STDDEV_SAMP, VAR_POP, VAR_SAMP, AUTO_INCREMENT, AVG_ROW_LENGTH, DELAY_KEY_WRITE, CURRENT_TIMESTAMP, ROTATE, MASTER, BINLOG, ERROR, SCHEDULE, COMPLETION, EVERY, HOST, SOCKET, PORT, SERVER, WRAPPER, OPTIONS, OWNER, RETURNS, CONTAINS, SECURITY, INVOKER, TEMPTABLE, MERGE, UNDEFINED, DATAFILE, FILE_BLOCK_SIZE, EXTENT_SIZE, INITIAL_SIZE, AUTOEXTEND_SIZE, MAX_SIZE, NODEGROUP, WAIT, LOGFILE, UNDOFILE, UNDO_BUFFER_SIZE, REDO_BUFFER_SIZE, HANDLER, PREV, ORGANIZATION, DEFINITION, DESCRIPTION, REFERENCE, FOLLOWS, PRECEDES, IMPORT, CONCURRENT, XML, DUMPFILE, SHARE, CODE, CONTEXT, SOURCE, CHANNEL, CLONE, AGGREGATE, INSTALL, COMPONENT, UNINSTALL, RESOURCE, EXPIRE, NEVER, HISTORY, OPTIONAL, REUSE, MAX_QUERIES_PER_HOUR, MAX_UPDATES_PER_HOUR, MAX_CONNECTIONS_PER_HOUR, MAX_USER_CONNECTIONS, RETAIN, RANDOM, OLD, ISSUER, SUBJECT, CACHE, GENERAL, SLOW, USER_RESOURCES, EXPORT, RELAY, HOSTS, FLUSH, RESET, RESTART, UNIX_TIMESTAMP, LOWER, UPPER, ADDDATE, ADDTIME, DATE_ADD, DATE_SUB, DATEDIFF, DATE_FORMAT, DAYNAME, DAYOFMONTH, DAYOFWEEK, DAYOFYEAR, STR_TO_DATE, TIMEDIFF, TIMESTAMPADD, TIMESTAMPDIFF, TIME_FORMAT, TIME_TO_SEC, AES_DECRYPT, AES_ENCRYPT, FROM_BASE64, TO_BASE64, GEOMCOLLECTION, GEOMETRYCOLLECTION, LINESTRING, MULTILINESTRING, MULTIPOINT, MULTIPOLYGON, POINT, POLYGON, ST_AREA, ST_ASBINARY, ST_ASGEOJSON, ST_ASTEXT, ST_ASWKB, ST_ASWKT, ST_BUFFER, ST_BUFFER_STRATEGY, ST_CENTROID, ST_CONTAINS, ST_CONVEXHULL, ST_CROSSES, ST_DIFFERENCE, ST_DIMENSION, ST_DISJOINT, ST_DISTANCE, ST_DISTANCE_SPHERE, ST_ENDPOINT, ST_ENVELOPE, ST_EQUALS, ST_EXTERIORRING, ST_GEOHASH, ST_GEOMCOLLFROMTEXT, ST_GEOMCOLLFROMTXT, ST_GEOMCOLLFROMWKB, ST_GEOMETRYCOLLECTIONFROMTEXT, ST_GEOMETRYCOLLECTIONFROMWKB, ST_GEOMETRYFROMTEXT, ST_GEOMETRYFROMWKB, ST_GEOMETRYN, ST_GEOMETRYTYPE, ST_GEOMFROMGEOJSON, ST_GEOMFROMTEXT, ST_GEOMFROMWKB, ST_INTERIORRINGN, ST_INTERSECTION, ST_INTERSECTS, ST_ISCLOSED, ST_ISEMPTY, ST_ISSIMPLE, ST_ISVALID, ST_LATFROMGEOHASH, ST_LATITUDE, ST_LENGTH, ST_LINEFROMTEXT, ST_LINEFROMWKB, ST_LINESTRINGFROMTEXT, ST_LINESTRINGFROMWKB, ST_LONGFROMGEOHASH, ST_LONGITUDE, ST_MAKEENVELOPE, ST_MLINEFROMTEXT, ST_MLINEFROMWKB, ST_MULTILINESTRINGFROMTEXT, ST_MULTILINESTRINGFROMWKB, ST_MPOINTFROMTEXT, ST_MPOINTFROMWKB, ST_MULTIPOINTFROMTEXT, ST_MULTIPOINTFROMWKB, ST_MPOLYFROMTEXT, ST_MPOLYFROMWKB, ST_MULTIPOLYGONFROMTEXT, ST_MULTIPOLYGONFROMWKB, ST_NUMGEOMETRIES, ST_NUMINTERIORRING, ST_NUMINTERIORRINGS, ST_NUMPOINTS, ST_OVERLAPS, ST_POINTFROMGEOHASH, ST_POINTFROMTEXT, ST_POINTFROMWKB, ST_POINTN, ST_POLYFROMTEXT, ST_POLYFROMWKB, ST_POLYGONFROMTEXT, ST_POLYGONFROMWKB, ST_SIMPLIFY, ST_SRID, ST_STARTPOINT, ST_SWAPXY, ST_SYMDIFFERENCE, ST_TOUCHES, ST_TRANSFORM, ST_UNION, ST_VALIDATE, ST_WITHIN, ST_X, ST_Y, IO_THREAD, SQL_THREAD, SQL_BEFORE_GTIDS, SQL_AFTER_GTIDS, MASTER_LOG_FILE, MASTER_LOG_POS, RELAY_LOG_FILE, RELAY_LOG_POS, SQL_AFTER_MTS_GAPS, UNTIL, DEFAULT_AUTH, PLUGINDIR, STOP, IDENTIFIER, STRING, NUMBER, HEXDIGIT, BITNUM}

java.lang.NullPointerException at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18) at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.createProjection(MySQLDMLVisitor.java:446) at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitProjection(MySQLDMLVisitor.java:434) at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitProjection(MySQLDMLVisitor.java:127) at org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser$ProjectionContext.accept(MySQLStatementParser.java:5370) at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18) at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitProjections(MySQLDMLVisitor.java:410) at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitProjections(MySQLDMLVisitor.java:127) at org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser$ProjectionsContext.accept(MySQLStatementParser.java:4865) at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18) at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitSelectClause(MySQLDMLVisitor.java:329) at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitSelectClause(MySQLDMLVisitor.java:127) at org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser$SelectClauseContext.accept(MySQLStatementParser.java:4551) at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18) at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitUnionClause(MySQLDMLVisitor.java:322) at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitUnionClause(MySQLDMLVisitor.java:127) at org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser$UnionClauseContext.accept(MySQLStatementParser.java:4446) at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18) at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitSelect(MySQLDMLVisitor.java:314) at org.apache.shardingsphere.sql.parser.mysql.visitor.impl.MySQLDMLVisitor.visitSelect(MySQLDMLVisitor.java:127) at org.apache.shardingsphere.sql.parser.autogen.MySQLStatementParser$SelectContext.accept(MySQLStatementParser.java:3098) at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18) at org.apache.shardingsphere.sql.parser.SQLParserEngine.parse0(SQLParserEngine.java:80) at org.apache.shardingsphere.sql.parser.SQLParserEngine.parse(SQLParserEngine.java:61) at com.example.nick1.ParserTest.testParse(ParserTest.java:15) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Process finished with exit code 255

Example codes for reproduce this issue (such as a github link).

public class ParserTest {

@Test
public void testParse(){
    SQLParserEngine parserEngine= SQLParserEngineFactory.getSQLParserEngine("MySQL");
    String sql="select user_id, name, profile from t_user where name=?";
    SQLStatement sqlStatement=parserEngine.parse(sql,false);
    Assert.notNull(sqlStatement,"statement should not be null");
}

}

jingshanglu commented 3 years ago

@springnick It has been fixed in the release 5.0.0-alpha. Plz use 5.0.0-alpha.

springnick commented 3 years ago

thanks for the quick response, I'll try it