Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-8497

SQL return ArrayIndexOutOfBoundsException when ends with '\n'

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • Impala 3.2.0
    • Impala 3.3.0
    • Frontend
    • None
    • ghx-label-6

    Description

      When submit sql with jdbc in code, those sqls return "ArrayIndexOutOfBoundsException" instead of "Syntax error":

      show\n
      select\n
      

      This is mainly caused by code below:

      //sql-parser.cup
        public String getErrorMsg(String stmt) {
          if (errorToken_ == null || stmt == null) return null;
          String[] lines = stmt.split("\n");
          StringBuffer result = new StringBuffer();
          result.append(getErrorTypeMessage(errorToken_.sym) + " in line ");
          result.append(errorToken_.left);
          result.append(":\n");
      
          // errorToken_.left is the line number of error.
          // errorToken_.right is the column number of the error.
          String errorLine = lines[errorToken_.left - 1];
          //......
      

      because these sqls are ends with '\n', the length of 'lines' array is small than 'errorToken_.left - 1', and thus throw ArrayIndexOutOfBoundsException, and this exception cannot be catched.

      Attachments

        Activity

          People

            skyyws Sheng Wang
            skyyws Sheng Wang
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: