Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-19896

Create view stores invalid, malformed version of original SQL text

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.2.1, 2.3.0
    • None
    • Views
    • None
    • Create view no longer malforms original SQL text

    Description

      We perform additional processing on some of our view definitions and we've found that in some cases Hive actually stores malformed representations of the original source SQL text definition of the view. We have examples where the stored original view text is in fact an unparsable statement. This prevents later processing of the view (recompiling for column adjustments for example) and is counter intuitive to the user.

      Specifically the failure appears to be focused on the removal of necessary back-tick quoting from the original text on aliases (but possibly other identifiers).

      Steps to reproduce (abridged/formatted for clarity):

      Create a view that is subject to malformation:

      hive> create view v as select * from (select 1) as `a.b`;
      OK
      

      Describe view definition to obtain original text:

      describe extended v;
      ...
      Detailed Table Information	Table(
        tableName:v,
        dbName:default,
        viewOriginalText:select * from (select 1) as a.b,
        viewExpandedText:select `a.b`.`_c0` from (select 1) as `a.b`,
        tableType:VIRTUAL_VIEW)
      

      Note that viewOriginalText value does not equal the text supplied on the first step, specifically `a.b`a.b.

      Executing viewOriginalText value results in failure:

      hive> select * from (select 1) as a.b;
      NoViableAltException(17@[215:51: ( KW_AS )?])
      	at org.antlr.runtime.DFA.noViableAlt(DFA.java:158)
      ...
      FAILED: ParseException line 1:29 cannot recognize input near 'as' 'a' '.' in subquery source
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              teabot Elliot West
              Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated: