Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-4019

Visit SqlInsert with SqlShuttle cause NullPointerException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.24.0
    • 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());
            }
          });
        }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            yanlin-Lynn Wang Yanlin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 3h 10m
                3h 10m