Fix UDAFPercentile ndexOutOfBoundsException
-------------------------------------------

                 Key: HIVE-1291
                 URL: https://issues.apache.org/jira/browse/HIVE-1291
             Project: Hadoop Hive
          Issue Type: Bug
    Affects Versions: 0.6.0
            Reporter: Zheng Shao
            Assignee: Zheng Shao


The counts array can be empty. We should directly return null in that case.

{code}
org.apache.hadoop.hive.ql.metadata.HiveException: Unable to execute method 
public org.apache.hadoop.hive.serde2.io.DoubleWritable 
org.apache.hadoop.hive.ql.udf.UDAFPercentile$PercentileLongEvaluator.terminate()
  on object 
org.apache.hadoop.hive.ql.udf.udafpercentile$percentilelongevalua...@530d0eae 
of class org.apache.hadoop.hive.ql.udf.UDAFPercentile$PercentileLongEvaluator 
with arguments {} of size 0
        at 
org.apache.hadoop.hive.ql.exec.FunctionRegistry.invoke(FunctionRegistry.java:725)
        at 
org.apache.hadoop.hive.ql.udf.generic.GenericUDAFBridge$GenericUDAFBridgeEvaluator.terminate(GenericUDAFBridge.java:181)
        at 
org.apache.hadoop.hive.ql.udf.generic.GenericUDAFEvaluator.evaluate(GenericUDAFEvaluator.java:157)
        at 
org.apache.hadoop.hive.ql.exec.GroupByOperator.forward(GroupByOperator.java:838)
        at 
org.apache.hadoop.hive.ql.exec.GroupByOperator.closeOp(GroupByOperator.java:885)
        at org.apache.hadoop.hive.ql.exec.Operator.close(Operator.java:539)
        at 
org.apache.hadoop.hive.ql.exec.ExecReducer.close(ExecReducer.java:300)
        at 
org.apache.hadoop.mapred.ReduceTask.runOldReducer(ReduceTask.java:474)
        at org.apache.hadoop.mapred.ReduceTask.run(ReduceTask.java:412)
        at org.apache.hadoop.mapred.Child.main(Child.java:159)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at 
org.apache.hadoop.hive.ql.exec.FunctionRegistry.invoke(FunctionRegistry.java:701)
        ... 9 more
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.RangeCheck(ArrayList.java:547)
        at java.util.ArrayList.get(ArrayList.java:322)
        at 
org.apache.hadoop.hive.ql.udf.UDAFPercentile.getPercentile(UDAFPercentile.java:97)
        at 
org.apache.hadoop.hive.ql.udf.UDAFPercentile.access$300(UDAFPercentile.java:44)
        at 
org.apache.hadoop.hive.ql.udf.UDAFPercentile$PercentileLongEvaluator.terminate(UDAFPercentile.java:196)
        ... 14 more
{code}


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to