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

SqlSimpleParser toke.s equals NullPointerException

    XMLWordPrintableJSON

Details

    Description

       

       

      SQL:

       

      select ^ from (select * from sales.emp ) a
      

      use SqlSimpleParser parse sql

      Exception:

       

       

       

      java.lang.NullPointerExceptionjava.lang.NullPointerException at org.apache.calcite.sql.advise.SqlSimpleParser$Query.contains(SqlSimpleParser.java:818) at org.apache.calcite.sql.advise.SqlSimpleParser$Query.simplify(SqlSimpleParser.java:548) at org.apache.calcite.sql.advise.SqlSimpleParser$Query.simplifyList(SqlSimpleParser.java:508) at org.apache.calcite.sql.advise.SqlSimpleParser.simplifySql(SqlSimpleParser.java:171) at org.apache.calcite.sql.advise.SqlSimpleParser.simplifySql(SqlSimpleParser.java:141) at org.apache.calcite.sql.advise.SqlAdvisor.simplifySql(SqlAdvisor.java:556) at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints0(SqlAdvisor.java:222) at org.apache.calcite.sql.advise.SqlAdvisor.getCompletionHints(SqlAdvisor.java:192)
      

       

       

      cause:

      SqlSimpleParser Token.s

      s is null

      private boolean contains(String hintToken) {
        for (Token token : tokenList) {
          switch (token.type) {
          case ID:
            // exception
            if (token.s.equals(hintToken)) {
              return true;
            }
            break;
          case QUERY:
            if (((Query) token).contains(hintToken)) {
              return true;
            }
            break;
          }
        }
        return false;
      }
      

       

       

       

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              quxiucheng quxiucheng
              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 - 0.5h
                  0.5h