Review Board 1.7.22


HIVE-3107: Improve semantic analyzer to better handle column name references in group by/sort by clauses

Review Request #15525 - Created Nov. 14, 2013 and submitted

Harish Butani
hive-3107
Reviewers
hive
ashutoshc, xuefuz
hive-git
Following queries all fail with various SemanticExceptions:
explain select t.c from t group by c;
explain select t.c from t group by c sort by t.c; 
explain select t.c as c0 from t group by c0;
explain select t.c from t group by t.c sort by t.c; 
added groupby_resolution.q that tests the jira listed.
Also added tests for having and windowing.
ql/src/java/org/apache/hadoop/hive/ql/parse/PTFTranslator.java
Revision 7a7f3ef New Change
[20] 932 lines
[+20] [+] protected RowResolver buildRowResolverForWindowing(WindowTableFunctionDef def)
933
      if (inExpr != null) {
933
      if (inExpr != null) {
934
        rr.putExpression(inExpr, cInfo);
934
        rr.putExpression(inExpr, cInfo);
935
      } else {
935
      } else {
936
        rr.put(cInfo.getTabAlias(), colAlias, cInfo);
936
        rr.put(cInfo.getTabAlias(), colAlias, cInfo);
937
      }
937
      }

    
   
938
      

    
   
939
      String[] altMapping = inputRR.getAlternateMappings(inpCInfo.getInternalName());

    
   
940
      if ( altMapping != null ) {

    
   
941
        rr.put(altMapping[0], altMapping[1], cInfo);

    
   
942
      }
938
    }
943
    }
939

    
   
944

   
940
    return rr;
945
    return rr;
941
  }
946
  }
942

    
   
947

   
[+20] [20] 197 lines
ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java
Revision 908546e New Change
 
ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
Revision d797407 New Change
 
ql/src/test/queries/clientnegative/notable_alias3.q
Revision 6cc3e87 New Change
 
ql/src/test/queries/clientpositive/groupby_resolution.q
New File
 
ql/src/test/queries/clientpositive/notable_alias3.q
New File
 
ql/src/test/results/clientnegative/notable_alias3.q.out
Revision cadca6e New Change
 
ql/src/test/results/clientpositive/groupby_resolution.q.out
New File
 
ql/src/test/results/clientpositive/notable_alias3.q.out
New File
 
ql/src/test/results/compiler/errors/nonkey_groupby.q.out
Revision a13d45d New Change
 
ql/src/test/results/compiler/plan/groupby1.q.xml
Revision 485c323 New Change
 
ql/src/test/results/compiler/plan/groupby5.q.xml
Revision abdbff0 New Change
 
  1. ql/src/java/org/apache/hadoop/hive/ql/parse/PTFTranslator.java: Loading...
  2. ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java: Loading...
  3. ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java: Loading...
  4. ql/src/test/queries/clientnegative/notable_alias3.q: Loading...
  5. ql/src/test/queries/clientpositive/groupby_resolution.q: Loading...
  6. ql/src/test/queries/clientpositive/notable_alias3.q: Loading...
  7. ql/src/test/results/clientnegative/notable_alias3.q.out: Loading...
  8. ql/src/test/results/clientpositive/groupby_resolution.q.out: Loading...
  9. ql/src/test/results/clientpositive/notable_alias3.q.out: Loading...
  10. ql/src/test/results/compiler/errors/nonkey_groupby.q.out: Loading...
  11. ql/src/test/results/compiler/plan/groupby1.q.xml: Loading...
  12. ql/src/test/results/compiler/plan/groupby5.q.xml: Loading...