hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject svn commit: r1616802 - in /hive/branches/cbo/ql/src: java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java test/queries/clientpositive/cbo_correctness.q test/results/clientpositive/cbo_correctness.q.out
Date Fri, 08 Aug 2014 15:26:07 GMT
Author: hashutosh
Date: Fri Aug  8 15:26:07 2014
New Revision: 1616802

URL: http://svn.apache.org/r1616802
Log:
HIVE-7636 : cbo fails when no projection is required from aggregate function (Ashutosh Chauhan)

Modified:
    hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
    hive/branches/cbo/ql/src/test/queries/clientpositive/cbo_correctness.q
    hive/branches/cbo/ql/src/test/results/clientpositive/cbo_correctness.q.out

Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java?rev=1616802&r1=1616801&r2=1616802&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java Fri
Aug  8 15:26:07 2014
@@ -12312,6 +12312,11 @@ public class SemanticAnalyzer extends Ba
             rexNodeToPosMap, gbChildProjLst.size()));
       }
 
+      if (gbChildProjLst.isEmpty()) {
+        // This will happen for count(*), in such cases we arbitarily pick
+        // first element from srcRel
+        gbChildProjLst.add(this.m_cluster.getRexBuilder().makeInputRef(srcRel, 0));
+      }
       RelNode gbInputRel = HiveProjectRel.create(srcRel, gbChildProjLst, null);
 
       HiveRel aggregateRel = null;
@@ -12539,7 +12544,7 @@ public class SemanticAnalyzer extends Ba
           obASTExpr = (ASTNode) obASTExprLst.get(i);
           Map<ASTNode, ExprNodeDesc> astToExprNDescMap = TypeCheckProcFactory
               .genExprNode(obASTExpr, new TypeCheckCtx(inputRR));
-          ExprNodeDesc obExprNDesc = astToExprNDescMap.get((ASTNode) obASTExpr
+          ExprNodeDesc obExprNDesc = astToExprNDescMap.get(obASTExpr
               .getChild(0));
           if (obExprNDesc == null)
             throw new SemanticException("Invalid order by expression: "
@@ -12575,6 +12580,7 @@ public class SemanticAnalyzer extends Ba
         if (!newVCLst.isEmpty()) {
           List<RexNode> originalInputRefs = Lists.transform(srcRel.getRowType()
               .getFieldList(), new Function<RelDataTypeField, RexNode>() {
+            @Override
             public RexNode apply(RelDataTypeField input) {
               return new RexInputRef(input.getIndex(), input.getType());
             }
@@ -12603,6 +12609,7 @@ public class SemanticAnalyzer extends Ba
           List<RexNode> obParentRelProjs = Lists.transform(srcRel
               .getRowType().getFieldList(),
               new Function<RelDataTypeField, RexNode>() {
+                @Override
                 public RexNode apply(RelDataTypeField input) {
                   return new RexInputRef(input.getIndex(), input.getType());
                 }
@@ -13033,6 +13040,7 @@ public class SemanticAnalyzer extends Ba
        */
       List<String> oFieldNames = Lists.transform(columnNames,
           new Function<String, String>() {
+            @Override
             public String apply(String hName) {
               return "_o_" + hName;
             }

Modified: hive/branches/cbo/ql/src/test/queries/clientpositive/cbo_correctness.q
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/test/queries/clientpositive/cbo_correctness.q?rev=1616802&r1=1616801&r2=1616802&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/test/queries/clientpositive/cbo_correctness.q (original)
+++ hive/branches/cbo/ql/src/test/queries/clientpositive/cbo_correctness.q Fri Aug  8 15:26:07
2014
@@ -189,9 +189,12 @@ select max(c_int) from v1 group by (c_bo
 select count(v1.c_int)  from v1 join t2 on v1.c_int = t2.c_int;
 select count(v1.c_int)  from v1 join v2 on v1.c_int = v2.c_int;
 
-create view v3 as select v1.value  from v1 join t1 on v1.c_boolean = t1.c_boolean;
-select * from v3 limit 3;
+select count(*) from v1 a join v1 b on a.value = b.value;
 
+create view v3 as select v1.value val from v1 join t1 on v1.c_boolean = t1.c_boolean;
+
+-- view chaining
+select count(val) from v3 where val != '1';
 with q1 as ( select key from t1 where key = '1')
 select *
 from q1
@@ -210,4 +213,7 @@ with q1 as ( select c_int from q2 where 
 q2 as ( select c_int,c_boolean from v1  where value = '1')
 select * from (select c_int from q1) a;
 
-
+drop view v1;
+drop view v2;
+drop view v3;
+drop view v4;

Modified: hive/branches/cbo/ql/src/test/results/clientpositive/cbo_correctness.q.out
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/test/results/clientpositive/cbo_correctness.q.out?rev=1616802&r1=1616801&r2=1616802&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/test/results/clientpositive/cbo_correctness.q.out (original)
+++ hive/branches/cbo/ql/src/test/results/clientpositive/cbo_correctness.q.out Fri Aug  8
15:26:07 2014
@@ -16013,30 +16013,41 @@ POSTHOOK: Input: default@v1
 POSTHOOK: Input: default@v2
 #### A masked pattern was here ####
 234
-PREHOOK: query: create view v3 as select v1.value  from v1 join t1 on v1.c_boolean = t1.c_boolean
+PREHOOK: query: select count(*) from v1 a join v1 b on a.value = b.value
+PREHOOK: type: QUERY
+PREHOOK: Input: default@t1
+PREHOOK: Input: default@v1
+#### A masked pattern was here ####
+POSTHOOK: query: select count(*) from v1 a join v1 b on a.value = b.value
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@t1
+POSTHOOK: Input: default@v1
+#### A masked pattern was here ####
+160
+PREHOOK: query: create view v3 as select v1.value val from v1 join t1 on v1.c_boolean = t1.c_boolean
 PREHOOK: type: CREATEVIEW
 PREHOOK: Input: default@t1
 PREHOOK: Input: default@v1
-POSTHOOK: query: create view v3 as select v1.value  from v1 join t1 on v1.c_boolean = t1.c_boolean
+POSTHOOK: query: create view v3 as select v1.value val from v1 join t1 on v1.c_boolean =
t1.c_boolean
 POSTHOOK: type: CREATEVIEW
 POSTHOOK: Input: default@t1
 POSTHOOK: Input: default@v1
 POSTHOOK: Output: default@v3
-PREHOOK: query: select * from v3 limit 3
+PREHOOK: query: -- view chaining
+select count(val) from v3 where val != '1'
 PREHOOK: type: QUERY
 PREHOOK: Input: default@t1
 PREHOOK: Input: default@v1
 PREHOOK: Input: default@v3
 #### A masked pattern was here ####
-POSTHOOK: query: select * from v3 limit 3
+POSTHOOK: query: -- view chaining
+select count(val) from v3 where val != '1'
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@t1
 POSTHOOK: Input: default@v1
 POSTHOOK: Input: default@v3
 #### A masked pattern was here ####
-1
-1
-1
+96
 PREHOOK: query: with q1 as ( select key from t1 where key = '1')
 select *
 from q1
@@ -16104,3 +16115,35 @@ POSTHOOK: Input: default@v1
 #### A masked pattern was here ####
 1
 1
+PREHOOK: query: drop view v1
+PREHOOK: type: DROPVIEW
+PREHOOK: Input: default@v1
+PREHOOK: Output: default@v1
+POSTHOOK: query: drop view v1
+POSTHOOK: type: DROPVIEW
+POSTHOOK: Input: default@v1
+POSTHOOK: Output: default@v1
+PREHOOK: query: drop view v2
+PREHOOK: type: DROPVIEW
+PREHOOK: Input: default@v2
+PREHOOK: Output: default@v2
+POSTHOOK: query: drop view v2
+POSTHOOK: type: DROPVIEW
+POSTHOOK: Input: default@v2
+POSTHOOK: Output: default@v2
+PREHOOK: query: drop view v3
+PREHOOK: type: DROPVIEW
+PREHOOK: Input: default@v3
+PREHOOK: Output: default@v3
+POSTHOOK: query: drop view v3
+POSTHOOK: type: DROPVIEW
+POSTHOOK: Input: default@v3
+POSTHOOK: Output: default@v3
+PREHOOK: query: drop view v4
+PREHOOK: type: DROPVIEW
+PREHOOK: Input: default@v4
+PREHOOK: Output: default@v4
+POSTHOOK: query: drop view v4
+POSTHOOK: type: DROPVIEW
+POSTHOOK: Input: default@v4
+POSTHOOK: Output: default@v4



Mime
View raw message