hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject [16/27] hive git commit: HIVE-12473 : DPP: UDFs on the partition column side does not evaluate correctly (Sergey Shelukhin, reviewed by Gopal V)
Date Mon, 30 Nov 2015 19:15:27 GMT
HIVE-12473 : DPP: UDFs on the partition column side does not evaluate correctly (Sergey Shelukhin,
reviewed by Gopal V)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/c7a939ad
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/c7a939ad
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/c7a939ad

Branch: refs/heads/master-fixed
Commit: c7a939ad44394f56ca8818d4cac064c62cb4c025
Parents: 39a8252
Author: Sergey Shelukhin <sershe@apache.org>
Authored: Wed Nov 25 12:15:29 2015 -0800
Committer: Owen O'Malley <omalley@apache.org>
Committed: Mon Nov 30 11:14:36 2015 -0800

----------------------------------------------------------------------
 .../ql/exec/tez/DynamicPartitionPruner.java     | 40 ++++++++++++++------
 1 file changed, 29 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/c7a939ad/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/DynamicPartitionPruner.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/DynamicPartitionPruner.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/DynamicPartitionPruner.java
index b67ac8d..60b71aa 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/DynamicPartitionPruner.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/tez/DynamicPartitionPruner.java
@@ -18,6 +18,12 @@
 
 package org.apache.hadoop.hive.ql.exec.tez;
 
+import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
+
+import org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc;
+
+import org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc;
+
 import java.io.DataInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -242,25 +248,37 @@ public class DynamicPartitionPruner {
       LOG.debug(sb.toString());
     }
 
-    ObjectInspector oi =
-        PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(TypeInfoFactory
-            .getPrimitiveTypeInfo(si.fieldInspector.getTypeName()));
+    ObjectInspector targetOi = findTargetOi(si.partKey, si.columnName);
+    Converter converter = ObjectInspectorConverters.getConverter(
+            PrimitiveObjectInspectorFactory.javaStringObjectInspector, targetOi);
 
-    Converter converter =
-        ObjectInspectorConverters.getConverter(
-            PrimitiveObjectInspectorFactory.javaStringObjectInspector, oi);
-
-    StructObjectInspector soi =
-        ObjectInspectorFactory.getStandardStructObjectInspector(
-            Collections.singletonList(columnName), Collections.singletonList(oi));
+    StructObjectInspector soi = ObjectInspectorFactory.getStandardStructObjectInspector(
+            Collections.singletonList(columnName), Collections.singletonList(targetOi));
 
     @SuppressWarnings("rawtypes")
     ExprNodeEvaluator eval = ExprNodeEvaluatorFactory.get(si.partKey);
-    eval.initialize(soi);
+    eval.initialize(soi); // We expect the row with just the relevant column.
 
     applyFilterToPartitions(converter, eval, columnName, values);
   }
 
+  private ObjectInspector findTargetOi(ExprNodeDesc expr, String columnName) {
+    if (expr instanceof ExprNodeColumnDesc) {
+      ExprNodeColumnDesc colExpr = (ExprNodeColumnDesc)expr;
+      // TODO: this is not necessarily going to work for all cases. At least, table name
is needed.
+      //       Also it's not clear if this is going to work with subquery columns and such.
+      if (columnName.equals(colExpr.getColumn())) {
+        return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(
+            (PrimitiveTypeInfo)colExpr.getTypeInfo());
+      }
+    }
+    for (ExprNodeDesc child : expr.getChildren()) {
+      ObjectInspector oi = findTargetOi(child, columnName);
+      if (oi != null) return oi;
+    }
+    return null;
+  }
+
   @SuppressWarnings("rawtypes")
   private void applyFilterToPartitions(Converter converter, ExprNodeEvaluator eval,
       String columnName, Set<Object> values) throws HiveException {


Mime
View raw message