Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
When visit a SqlInsert with SqlShuttle, got NPE, the stack trace is
java.lang.NullPointerException at com.google.common.collect.Iterators$8.transform(Iterators.java:817) at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48) at org.apache.calcite.sql.parser.SqlParserPos.sum(SqlParserPos.java:274) at org.apache.calcite.sql.parser.SqlParserPos.plusAll(SqlParserPos.java:183) at org.apache.calcite.sql.SqlOperator.createCall(SqlOperator.java:251) at org.apache.calcite.sql.util.SqlShuttle$CallCopyingArgHandler.result(SqlShuttle.java:117) at org.apache.calcite.sql.util.SqlShuttle$CallCopyingArgHandler.result(SqlShuttle.java:101) at org.apache.calcite.sql.util.SqlShuttle.visit(SqlShuttle.java:67) at org.apache.calcite.sql.util.SqlShuttle.visit(SqlShuttle.java:39) at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:139) at org.apache.calcite.sql.parser.SqlParserTest.testSqlParserPosPlus(SqlParserTest.java:8791)
Add this case in SqlParserTest to reproduce.
return a new same SqlIdentifier for each SqlIdentifier, make sure update
happends
@Test void testSqlParserPosPlus() throws Exception { final String sql = "insert into emps select * from emps"; SqlNode sqlNode = getSqlParser(sql).parseStmt(); sqlNode.accept(new SqlShuttle(){ @Override public SqlNode visit(SqlIdentifier identifier) { return new SqlIdentifier(identifier.names, identifier.getParserPosition()); } }); }