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 2018/06/29 03:30:38 UTC
hive git commit: HIVE-18786 : NPE in Hive windowing functions
(Dongwook Kwon via Ashutosh Chauhan)
Repository: hive
Updated Branches:
refs/heads/master 1b3ac733f -> 5b2cbb548
HIVE-18786 : NPE in Hive windowing functions (Dongwook Kwon via Ashutosh Chauhan)
Signed-off-by: Ashutosh Chauhan <ha...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/5b2cbb54
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/5b2cbb54
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/5b2cbb54
Branch: refs/heads/master
Commit: 5b2cbb5489ffc672e1eb7ee40b8eaa50fd26115e
Parents: 1b3ac73
Author: Ashutosh Chauhan <ha...@apache.org>
Authored: Thu Jun 28 20:29:29 2018 -0700
Committer: Ashutosh Chauhan <ha...@apache.org>
Committed: Thu Jun 28 20:29:29 2018 -0700
----------------------------------------------------------------------
.../ql/udf/generic/GenericUDAFEvaluator.java | 1 +
.../udf/generic/TestGenericUDAFEvaluator.java | 79 ++++++++++++++++++++
2 files changed, 80 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/5b2cbb54/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 3a3e4b6..b02ca07 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
@@ -149,6 +149,7 @@ public abstract class GenericUDAFEvaluator implements Closeable {
// This function should be overriden in every sub class
// And the sub class should call super.init(m, parameters) to get mode set.
mode = m;
+ partitionEvaluator = null;
return null;
}
http://git-wip-us.apache.org/repos/asf/hive/blob/5b2cbb54/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDAFEvaluator.java
----------------------------------------------------------------------
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDAFEvaluator.java b/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDAFEvaluator.java
new file mode 100644
index 0000000..0747fa1
--- /dev/null
+++ b/ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDAFEvaluator.java
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.udf.generic;
+
+import org.apache.hadoop.hive.ql.exec.PTFPartition;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.plan.ptf.PTFExpressionDef;
+import org.apache.hadoop.hive.ql.plan.ptf.WindowFrameDef;
+import org.apache.hadoop.hive.ql.udf.ptf.BasePartitionEvaluator;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import java.util.Collections;
+import java.util.List;
+
+@RunWith(MockitoJUnitRunner.class)
+public class TestGenericUDAFEvaluator {
+
+ @Mock(answer = Answers.CALLS_REAL_METHODS)
+ private GenericUDAFEvaluator udafEvaluator;
+
+ @Mock
+ private WindowFrameDef winFrame;
+
+ @Mock
+ private PTFPartition partition1;
+
+ @Mock
+ private ObjectInspector outputOI;
+
+ private List<PTFExpressionDef> parameters = Collections.emptyList();
+
+ @Test
+ public void testGetPartitionWindowingEvaluatorWithoutInitCall() {
+ BasePartitionEvaluator partition1Evaluator1 = udafEvaluator.getPartitionWindowingEvaluator(
+ winFrame, partition1, parameters, outputOI);
+
+ BasePartitionEvaluator partition1Evaluator2 = udafEvaluator.getPartitionWindowingEvaluator(
+ winFrame, partition1, parameters, outputOI);
+
+ Assert.assertEquals(partition1Evaluator1, partition1Evaluator2);
+ }
+
+ @Test
+ public void testGetPartitionWindowingEvaluatorWithInitCall() throws HiveException {
+ BasePartitionEvaluator partition1Evaluator1 = udafEvaluator.getPartitionWindowingEvaluator(
+ winFrame, partition1, parameters, outputOI);
+
+ udafEvaluator.init(GenericUDAFEvaluator.Mode.COMPLETE, null);
+
+ BasePartitionEvaluator newPartitionEvaluator = udafEvaluator.getPartitionWindowingEvaluator(
+ winFrame, partition1, parameters, outputOI);
+
+ Assert.assertNotEquals(partition1Evaluator1, newPartitionEvaluator);
+ }
+
+}