[ 
https://issues.apache.org/jira/browse/CALCITE-4019?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17114570#comment-17114570
 ] 

Wang Yanlin commented on CALCITE-4019:
--------------------------------------

Thanks [~xzh_dz] for following this jira, feel free to work on this.

> Visit SqlInsert with SqlShuttle cause NullPointerException
> ----------------------------------------------------------
>
>                 Key: CALCITE-4019
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4019
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Wang Yanlin
>            Priority: Major
>
> When visit a SqlInsert with SqlShuttle, got NPE, the stack trace is
> {noformat}
> 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)
> {noformat}
> Add this case in SqlParserTest to reproduce.
>  return a new same SqlIdentifier for each SqlIdentifier, make sure 
> [update|https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/sql/util/SqlShuttle.java#L117]
>  
>  happends
> {noformat}
> @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());
>       }
>     });
>   }
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to