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

ToSqlUtils does not correctly quote lower-case Hive keywords

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • Impala 3.0
    • Impala 3.2.0
    • Frontend
    • None
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: