You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2014/09/18 01:23:54 UTC

svn commit: r1625852 - in /hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql: optimizer/optiq/RelOptHiveTable.java optimizer/optiq/reloperators/HiveProjectRel.java parse/SemanticAnalyzer.java

Author: hashutosh
Date: Wed Sep 17 23:23:54 2014
New Revision: 1625852

URL: http://svn.apache.org/r1625852
Log:
HIVE-8166 : CBO: 1) Bailout in strict mode 2) OB,LIMIT RR table alias is same as that of sub query 3) If RowCount Not found then fall back to non cbo 4)Fix NPE in unique col name check (John Pullokkaran via Ashutosh Chauhan)

Modified:
    hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/RelOptHiveTable.java
    hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/reloperators/HiveProjectRel.java
    hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java

Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/RelOptHiveTable.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/RelOptHiveTable.java?rev=1625852&r1=1625851&r2=1625852&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/RelOptHiveTable.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/RelOptHiveTable.java Wed Sep 17 23:23:54 2014
@@ -131,6 +131,9 @@ public class RelOptHiveTable extends Rel
       }
     }
 
+    if (rowCount == -1)
+      noColsMissingStats.getAndIncrement();
+
     return rowCount;
   }
 

Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/reloperators/HiveProjectRel.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/reloperators/HiveProjectRel.java?rev=1625852&r1=1625851&r2=1625852&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/reloperators/HiveProjectRel.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/reloperators/HiveProjectRel.java Wed Sep 17 23:23:54 2014
@@ -86,7 +86,7 @@ public class HiveProjectRel extends Proj
     RelOptCluster cluster = child.getCluster();
 
     // 1 Ensure columnNames are unique - OPTIQ-411
-    if (!Util.isDistinct(fieldNames)) {
+    if (fieldNames != null && !Util.isDistinct(fieldNames)) {
       String msg = "Select list contains multiple expressions with the same name." + fieldNames;
       throw new OptiqSemanticException(msg);
     }

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=1625852&r1=1625851&r2=1625852&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 Wed Sep 17 23:23:54 2014
@@ -12139,6 +12139,7 @@ public class SemanticAnalyzer extends Ba
     // 1. If top level QB is query then everything below it must also be Query
     // 2. Nested Subquery will return false for qbToChk.getIsQuery()
     if ((!topLevelQB || qbToChk.getIsQuery())
+        && (!conf.getBoolVar(ConfVars.HIVE_IN_TEST) || conf.getVar(ConfVars.HIVEMAPREDMODE).equalsIgnoreCase("nonstrict"))
         && (!topLevelQB || (queryProperties.getJoinCount() > 1) || conf.getBoolVar(ConfVars.HIVE_IN_TEST))
         && !queryProperties.hasClusterBy() && !queryProperties.hasDistributeBy()
         && !queryProperties.hasSortBy() && !queryProperties.hasPTF()
@@ -13870,7 +13871,6 @@ public class SemanticAnalyzer extends Ba
         aliasToRel.put(tableAlias, op);
       }
 
-
       if (aliasToRel.isEmpty()) {
         //// This may happen for queries like select 1; (no source table)
         // We can do following which is same, as what Hive does.
@@ -13910,7 +13910,15 @@ public class SemanticAnalyzer extends Ba
       selectRel = genSelectLogicalPlan(qb, srcRel);
       srcRel = (selectRel == null) ? srcRel : selectRel;
 
-      // 6. Incase this QB corresponds to subquery then modify its RR to point
+      // 6. Build Rel for OB Clause
+      obRel = genOBLogicalPlan(qb, srcRel);
+      srcRel = (obRel == null) ? srcRel : obRel;
+
+      // 7. Build Rel for Limit Clause
+      limitRel = genLimitLogicalPlan(qb, srcRel);
+      srcRel = (limitRel == null) ? srcRel : limitRel;
+
+      // 8. Incase this QB corresponds to subquery then modify its RR to point
       // to subquery alias
       // TODO: cleanup this
       if (qb.getParseInfo().getAlias() != null) {
@@ -13932,14 +13940,6 @@ public class SemanticAnalyzer extends Ba
         relToHiveColNameOptiqPosMap.put(srcRel, buildHiveToOptiqColumnMap(newRR, srcRel));
       }
 
-      // 7. Build Rel for OB Clause
-      obRel = genOBLogicalPlan(qb, srcRel);
-      srcRel = (obRel == null) ? srcRel : obRel;
-
-      // 8. Build Rel for Limit Clause
-      limitRel = genLimitLogicalPlan(qb, srcRel);
-      srcRel = (limitRel == null) ? srcRel : limitRel;
-
       if (LOG.isDebugEnabled()) {
         LOG.debug("Created Plan for Query Block " + qb.getId());
       }