You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by kg...@apache.org on 2017/11/22 08:28:14 UTC

hive git commit: HIVE-18105: Aggregation of an empty set doesn't pass constants to the UDAF (Zoltan Haindrich, reviewed by Ashutosh Chauhan)

Repository: hive
Updated Branches:
  refs/heads/master c5539a1b1 -> d22784a9e


HIVE-18105: Aggregation of an empty set doesn't pass constants to the UDAF (Zoltan Haindrich, reviewed by Ashutosh Chauhan)

Signed-off-by: Zoltan Haindrich <ki...@rxd.hu>


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

Branch: refs/heads/master
Commit: d22784a9e58d37a5e096029ad55f82ed46491500
Parents: c5539a1
Author: Zoltan Haindrich <ki...@rxd.hu>
Authored: Wed Nov 22 09:23:46 2017 +0100
Committer: Zoltan Haindrich <ki...@rxd.hu>
Committed: Wed Nov 22 09:24:16 2017 +0100

----------------------------------------------------------------------
 .../hadoop/hive/ql/exec/GroupByOperator.java    | 20 --------------
 .../ql/udf/generic/GenericUDAFEvaluator.java    | 28 +++++++++++---------
 2 files changed, 15 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/d22784a9/ql/src/java/org/apache/hadoop/hive/ql/exec/GroupByOperator.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/GroupByOperator.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/GroupByOperator.java
index 4a0acb1..8b94d1d 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/GroupByOperator.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/GroupByOperator.java
@@ -1098,26 +1098,6 @@ public class GroupByOperator extends Operator<GroupByDesc> {
         if (firstRow && GroupByOperator.shouldEmitSummaryRow(conf)) {
           firstRow = false;
 
-          // There is no grouping key - simulate a null row
-          // This is based on the assumption that a null row is ignored by
-          // aggregation functions
-          for (int ai = 0; ai < aggregations.length; ai++) {
-
-            // o is set to NULL in order to distinguish no rows at all
-            Object[] o;
-            if (aggregationParameterFields[ai].length > 0) {
-              o = new Object[aggregationParameterFields[ai].length];
-            } else {
-              o = null;
-            }
-
-            // Calculate the parameters
-            for (int pi = 0; pi < aggregationParameterFields[ai].length; pi++) {
-              o[pi] = null;
-            }
-            aggregationEvaluators[ai].aggregate(aggregations[ai], o);
-          }
-
           Object[] keys=new Object[outputKeyLength];
           int pos = conf.getGroupingSetPosition();
           if (pos >= 0 && pos < outputKeyLength) {

http://git-wip-us.apache.org/repos/asf/hive/blob/d22784a9/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFEvaluator.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFEvaluator.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFEvaluator.java
index f873011..1b7d8c9 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFEvaluator.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFEvaluator.java
@@ -39,9 +39,9 @@ import org.apache.hive.common.util.AnnotationUtils;
 /**
  * A Generic User-defined aggregation function (GenericUDAF) for the use with
  * Hive.
- * 
+ *
  * New GenericUDAF classes need to inherit from this GenericUDAF class.
- * 
+ *
  * The GenericUDAF are superior to normal UDAFs in the following ways: 1. It can
  * accept arguments of complex types, and return complex types. 2. It can accept
  * variable length of arguments. 3. It can accept an infinite number of function
@@ -115,7 +115,7 @@ public abstract class GenericUDAFEvaluator implements Closeable {
 
   /**
    * Initialize the evaluator.
-   * 
+   *
    * @param m
    *          The mode of aggregation.
    * @param parameters
@@ -127,7 +127,7 @@ public abstract class GenericUDAFEvaluator implements Closeable {
    *         mode, the ObjectInspector for the return value of
    *         terminatePartial() call; In FINAL and COMPLETE mode, the
    *         ObjectInspector for the return value of terminate() call.
-   * 
+   *
    *         NOTE: We need ObjectInspector[] (in addition to the TypeInfo[] in
    *         GenericUDAFResolver) for 2 reasons: 1. ObjectInspector contains
    *         more information than TypeInfo; and GenericUDAFEvaluator.init at
@@ -144,16 +144,17 @@ public abstract class GenericUDAFEvaluator implements Closeable {
   /**
    * The interface for a class that is used to store the aggregation result
    * during the process of aggregation.
-   * 
+   *
    * We split this piece of data out because there can be millions of instances
    * of this Aggregation in hash-based aggregation process, and it's very
    * important to conserve memory.
-   * 
+   *
    * In the future, we may completely hide this class inside the Evaluator and
    * use integer numbers to identify which aggregation we are looking at.
    *
    * @deprecated use {@link AbstractAggregationBuffer} instead
    */
+  @Deprecated
   public static interface AggregationBuffer {
   };
 
@@ -183,13 +184,14 @@ public abstract class GenericUDAFEvaluator implements Closeable {
    * Close GenericUDFEvaluator.
    * This is only called in runtime of MapRedTask.
    */
+  @Override
   public void close() throws IOException {
   }
 
   /**
    * This function will be called by GroupByOperator when it sees a new input
    * row.
-   * 
+   *
    * @param agg
    *          The object to store the aggregation result.
    * @param parameters
@@ -207,7 +209,7 @@ public abstract class GenericUDAFEvaluator implements Closeable {
   /**
    * This function will be called by GroupByOperator when it sees a new input
    * row.
-   * 
+   *
    * @param agg
    *          The object to store the aggregation result.
    */
@@ -221,7 +223,7 @@ public abstract class GenericUDAFEvaluator implements Closeable {
 
   /**
    * Iterate through original data.
-   * 
+   *
    * @param parameters
    *          The objects of parameters.
    */
@@ -229,7 +231,7 @@ public abstract class GenericUDAFEvaluator implements Closeable {
 
   /**
    * Get partial aggregation result.
-   * 
+   *
    * @return partial aggregation result.
    */
   public abstract Object terminatePartial(AggregationBuffer agg) throws HiveException;
@@ -237,7 +239,7 @@ public abstract class GenericUDAFEvaluator implements Closeable {
   /**
    * Merge with partial aggregation result. NOTE: null might be passed in case
    * there is no input data.
-   * 
+   *
    * @param partial
    *          The partial aggregation result.
    */
@@ -245,7 +247,7 @@ public abstract class GenericUDAFEvaluator implements Closeable {
 
   /**
    * Get final aggregation result.
-   * 
+   *
    * @return final aggregation result.
    */
   public abstract Object terminate(AggregationBuffer agg) throws HiveException;
@@ -260,7 +262,7 @@ public abstract class GenericUDAFEvaluator implements Closeable {
    * This method is called after this Evaluator is initialized. The returned
    * Function must be initialized. It is passed the 'window' of aggregation for
    * each row.
-   * 
+   *
    * @param wFrmDef
    *          the Window definition in play for this evaluation.
    * @return null implies that this fn cannot be processed in Streaming mode. So