You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by se...@apache.org on 2014/10/29 20:24:00 UTC

svn commit: r1635265 - in /hive/branches/branch-0.14/ql/src: java/org/apache/hadoop/hive/ql/exec/ColumnInfo.java java/org/apache/hadoop/hive/ql/parse/RowResolver.java test/results/clientpositive/tez/cbo_correctness.q.out

Author: sershe
Date: Wed Oct 29 19:23:59 2014
New Revision: 1635265

URL: http://svn.apache.org/r1635265
Log:
HIVE-8620 : CBO: HIVE-8433 RowResolver check is too stringent (Sergey Shelukhin, reviewed by Ashutosh Chauhan)

Modified:
    hive/branches/branch-0.14/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnInfo.java
    hive/branches/branch-0.14/ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java
    hive/branches/branch-0.14/ql/src/test/results/clientpositive/tez/cbo_correctness.q.out

Modified: hive/branches/branch-0.14/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnInfo.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnInfo.java?rev=1635265&r1=1635264&r2=1635265&view=diff
==============================================================================
--- hive/branches/branch-0.14/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnInfo.java (original)
+++ hive/branches/branch-0.14/ql/src/java/org/apache/hadoop/hive/ql/exec/ColumnInfo.java Wed Oct 29 19:23:59 2014
@@ -208,6 +208,7 @@ public class ColumnInfo implements Seria
       return false;
     }
 
+    // TODO: why does this not compare tabAlias?
     ColumnInfo dest = (ColumnInfo)obj;
     if ((!checkEquals(internalName, dest.getInternalName())) ||
         (!checkEquals(alias, dest.getAlias())) ||
@@ -221,6 +222,18 @@ public class ColumnInfo implements Seria
     return true;
   }
 
+  public boolean isSameColumnForRR(ColumnInfo other) {
+    return checkEquals(tabAlias, other.tabAlias)
+        && checkEquals(alias, other.alias)
+        && checkEquals(internalName, other.internalName)
+        && checkEquals(getType(), other.getType());
+  }
+
+  public String toMappingString(String tab, String col) {
+    return tab + "." + col + " => {" + tabAlias + ", " + alias + ", "
+        + internalName + ": " + getType() + "}";
+  }
+
   public void setObjectinspector(ObjectInspector writableObjectInspector) {
     this.objectInspector = writableObjectInspector;
   }

Modified: hive/branches/branch-0.14/ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java?rev=1635265&r1=1635264&r2=1635265&view=diff
==============================================================================
--- hive/branches/branch-0.14/ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java (original)
+++ hive/branches/branch-0.14/ql/src/java/org/apache/hadoop/hive/ql/parse/RowResolver.java Wed Oct 29 19:23:59 2014
@@ -403,21 +403,27 @@ public class RowResolver implements Seri
   public boolean putWithCheck(String tabAlias, String colAlias,
       String internalName, ColumnInfo newCI) throws SemanticException {
     ColumnInfo existing = get(tabAlias, colAlias);
+    // Hive adds the same mapping twice... I wish we could fix stuff like that.
     if (existing == null) {
       put(tabAlias, colAlias, newCI);
       return true;
+    } else if (existing.isSameColumnForRR(newCI)) {
+      return true;
     }
-    LOG.warn("Found duplicate column alias in RR: " + existing + " for "
-        + tabAlias + "." + colAlias + " and " + internalName);
+    LOG.warn("Found duplicate column alias in RR: "
+        + existing.toMappingString(tabAlias, colAlias) + " adding "
+        + newCI.toMappingString(tabAlias, colAlias));
     if (internalName != null) {
       existing = get(tabAlias, internalName);
       if (existing == null) {
         put(tabAlias, internalName, newCI);
         return true;
+      } else if (existing.isSameColumnForRR(newCI)) {
+        return true;
       }
+      LOG.warn("Failed to use internal name after finding a duplicate: "
+          + existing.toMappingString(tabAlias, internalName));
     }
-    LOG.warn("Failed to use internal name after finding a duplicate: " + existing
-        + " for " + tabAlias + "." + internalName);
     return false;
   }
 

Modified: hive/branches/branch-0.14/ql/src/test/results/clientpositive/tez/cbo_correctness.q.out
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/ql/src/test/results/clientpositive/tez/cbo_correctness.q.out?rev=1635265&r1=1635264&r2=1635265&view=diff
==============================================================================
--- hive/branches/branch-0.14/ql/src/test/results/clientpositive/tez/cbo_correctness.q.out (original)
+++ hive/branches/branch-0.14/ql/src/test/results/clientpositive/tez/cbo_correctness.q.out Wed Oct 29 19:23:59 2014
@@ -16734,26 +16734,6 @@ POSTHOOK: Input: default@t1@dt=2014
 POSTHOOK: Input: default@t2
 POSTHOOK: Input: default@t2@dt=2014
 #### A masked pattern was here ####
- 1	 1	1	1.0	true	2014
- 1	 1	1	1.0	true	2014
- 1 	 1 	1	1.0	true	2014
- 1 	 1 	1	1.0	true	2014
-1	1	1	1.0	false	2014
-1	1	1	1.0	false	2014
-1	1	1	1.0	true	2014
-1	1	1	1.0	true	2014
-1	1	1	1.0	true	2014
-1	1	1	1.0	true	2014
-1	1	1	1.0	true	2014
-1 	1 	1	1.0	true	2014
-1 	1 	1	1.0	true	2014
-2	2	2	2.0	true	2014
-2	2	2	2.0	true	2014
-2	2	2	2.0	true	2014
-2	2	2	2.0	true	2014
-2	2	2	2.0	true	2014
-null	null	NULL	NULL	NULL	2014
-null	null	NULL	NULL	NULL	2014
 1	1	1	1.0	true	2014
 1	1	1	1.0	true	2014
 1	1	1	1.0	true	2014
@@ -16774,6 +16754,26 @@ null	null	NULL	NULL	NULL	2014
 1	1	1	1.0	false	2014
 null	null	NULL	NULL	NULL	2014
 null	null	NULL	NULL	NULL	2014
+ 1	 1	1	1.0	true	2014
+ 1	 1	1	1.0	true	2014
+ 1 	 1 	1	1.0	true	2014
+ 1 	 1 	1	1.0	true	2014
+1	1	1	1.0	false	2014
+1	1	1	1.0	false	2014
+1	1	1	1.0	true	2014
+1	1	1	1.0	true	2014
+1	1	1	1.0	true	2014
+1	1	1	1.0	true	2014
+1	1	1	1.0	true	2014
+1 	1 	1	1.0	true	2014
+1 	1 	1	1.0	true	2014
+2	2	2	2.0	true	2014
+2	2	2	2.0	true	2014
+2	2	2	2.0	true	2014
+2	2	2	2.0	true	2014
+2	2	2	2.0	true	2014
+null	null	NULL	NULL	NULL	2014
+null	null	NULL	NULL	NULL	2014
 PREHOOK: query: select key from (select key, c_int from (select * from t1 union all select * from t2 where t2.key >=0)r1 union all select key, c_int from t3)r2 where key >=0 order by key
 PREHOOK: type: QUERY
 PREHOOK: Input: default@t1