public boolean iterate(LongWritable o, Double percentile) {
      if (o == null && percentile == null) {
        return false;
      }
      if (state.percentiles == null) {
        if (percentile < 0.0 || percentile > 1.0) {
          throw new RuntimeException("Percentile value must be within the range of 0 to 1.");
        }
        state.percentiles = Collections.singletonList(new DoubleWritable(percentile.doubleValue()));
      }
      if (o != null) {
        increment(state, o, 1);
      }
      return true;
    }
Note that percentile can be null in a global aggregation with
 0 input rows:  "select percentile(col, 0.5) from t where false"
 In that case, iterate(null, null) will be called once.
ql/src/java/org/apache/hadoop/hive/ql/udf/UDAFPercentile.java