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

ToSqlUtils does not correctly quote lower-case Hive keywords

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: Impala 3.0
    • Fix Version/s: Impala 3.2.0
    • Component/s: Frontend
    • Labels:
      None
    • Epic Color:
      ghx-label-9

      Description

      Not sure yet how to reproduce this error via the shell, but here is the code analysis.

      The ToSqlUtils class generates a CREATE TABLE statement, which uses a method getIdentSql() to possibly quote a table or column name. This same method is used in multiple places in the toSql() logic for various statements.

      The comment for the method says:

      returns an identifier lexable by Impala and Hive, possibly by enclosing the original identifier in "`" quotes.

      To check for a Hive-compatible identifier, the code uses the Hive lexer:

          HiveLexer hiveLexer = new HiveLexer(new ANTLRStringStream(ident));
      

      A unit test shows that this logic fails to catch lower case keywords: "select", say, while it does catch upper-case keywords: "SELECT".

      Checking the Hive source, it appears we're using the lexer wrong:

          HiveLexerX lexer = new HiveLexerX(new ANTLRNoCaseStringStream(command));
      

      The fix is simple: upper-case the symbol before using he Hive lexer.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Paul.Rogers Paul Rogers
                Reporter:
                Paul.Rogers Paul Rogers
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: