hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject [04/41] hive git commit: HIVE-11817: Window function max NullPointerException (Jimmy, reviewed by Szehon)
Date Fri, 18 Sep 2015 20:35:09 GMT
HIVE-11817: Window function max NullPointerException (Jimmy, reviewed by Szehon)


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

Branch: refs/heads/llap
Commit: 5548a9c376c2c59cbad9788689e58daa1a11f21e
Parents: 07ca812
Author: Jimmy Xiang <jxiang@cloudera.com>
Authored: Mon Sep 14 12:47:18 2015 -0700
Committer: Jimmy Xiang <jxiang@cloudera.com>
Committed: Tue Sep 15 09:14:38 2015 -0700

----------------------------------------------------------------------
 .../hadoop/hive/ql/udf/generic/GenericUDAFMax.java  | 16 +++++++++-------
 ql/src/test/queries/clientpositive/windowing_udaf.q |  4 ++++
 .../results/clientpositive/windowing_udaf.q.out     | 12 ++++++++++++
 3 files changed, 25 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/5548a9c3/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFMax.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFMax.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFMax.java
index 33600f2..55a6a62 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFMax.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFMax.java
@@ -287,14 +287,16 @@ public class GenericUDAFMax extends AbstractGenericUDAFResolver {
       // For the case: X following and Y following, process first Y-X results and then insert
X nulls.
       // For the case X preceding and Y following, process Y results.
       for (int i = Math.max(0, wFrameDef.getStart().getRelativeOffset()); i < wFrameDef.getEnd().getRelativeOffset();
i++) {
-        s.results.add(r[0]);
+        s.results.add(r == null ? null : r[0]);
         s.numRows++;
-        int fIdx = (Integer) r[1];
-        if (!wFrameDef.isStartUnbounded()
-            && s.numRows + i >= fIdx + wFrameDef.getWindowSize()
-            && !s.maxChain.isEmpty()) {
-          s.maxChain.removeFirst();
-          r = !s.maxChain.isEmpty() ? s.maxChain.getFirst() : r;
+        if (r != null) {
+          int fIdx = (Integer) r[1];
+          if (!wFrameDef.isStartUnbounded()
+              && s.numRows + i >= fIdx + wFrameDef.getWindowSize()
+              && !s.maxChain.isEmpty()) {
+            s.maxChain.removeFirst();
+            r = !s.maxChain.isEmpty() ? s.maxChain.getFirst() : r;
+          }
         }
       }
       for (int i = 0; i < wFrameDef.getStart().getRelativeOffset(); i++) {

http://git-wip-us.apache.org/repos/asf/hive/blob/5548a9c3/ql/src/test/queries/clientpositive/windowing_udaf.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/windowing_udaf.q b/ql/src/test/queries/clientpositive/windowing_udaf.q
index 0173ab7..45c5e5b 100644
--- a/ql/src/test/queries/clientpositive/windowing_udaf.q
+++ b/ql/src/test/queries/clientpositive/windowing_udaf.q
@@ -26,3 +26,7 @@ select s, avg(i) over (partition by t, b order by s) from over10k limit
100;
 select max(i) over w from over10k window w as (partition by f) limit 100;
 
 select s, avg(d) over (partition by t order by f) from over10k limit 100;
+
+select key, max(value) over
+  (order by key rows between 10 preceding and 20 following)
+from src1 where length(key) > 10;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/5548a9c3/ql/src/test/results/clientpositive/windowing_udaf.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/windowing_udaf.q.out b/ql/src/test/results/clientpositive/windowing_udaf.q.out
index 9d50251..298c1dd 100644
--- a/ql/src/test/results/clientpositive/windowing_udaf.q.out
+++ b/ql/src/test/results/clientpositive/windowing_udaf.q.out
@@ -584,3 +584,15 @@ zach zipper	19.822727272727274
 ulysses king	18.273333333333333
 bob king	17.664615384615384
 luke carson	18.02785714285714
+PREHOOK: query: select key, max(value) over
+  (order by key rows between 10 preceding and 20 following)
+from src1 where length(key) > 10
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src1
+#### A masked pattern was here ####
+POSTHOOK: query: select key, max(value) over
+  (order by key rows between 10 preceding and 20 following)
+from src1 where length(key) > 10
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src1
+#### A masked pattern was here ####


Mime
View raw message