You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jc...@apache.org on 2019/10/21 19:36:05 UTC

[hive] branch master updated: HIVE-22240: Function percentile_cont fails when array parameter passed (Krisztian Kasa, reviewed by Jesus Camacho Rodriguez)

This is an automated email from the ASF dual-hosted git repository.

jcamacho pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 72094da  HIVE-22240: Function percentile_cont fails when array parameter passed (Krisztian Kasa, reviewed by Jesus Camacho Rodriguez)
72094da is described below

commit 72094da54622f27215ee88878fbe78161e2757bb
Author: Krisztian Kasa <kk...@cloudera.com>
AuthorDate: Mon Oct 21 12:35:11 2019 -0700

    HIVE-22240: Function percentile_cont fails when array parameter passed (Krisztian Kasa, reviewed by Jesus Camacho Rodriguez)
---
 .../ql/udf/generic/GenericUDAFPercentileCont.java  | 132 +++++--
 .../ql/udf/generic/GenericUDAFPercentileDisc.java  |  41 +-
 .../queries/clientpositive/udaf_percentile_cont.q  |  14 +-
 .../queries/clientpositive/udaf_percentile_disc.q  |  14 +-
 .../clientpositive/udaf_percentile_cont.q.out      | 424 +++++++++++----------
 .../clientpositive/udaf_percentile_disc.q.out      | 424 +++++++++++----------
 6 files changed, 596 insertions(+), 453 deletions(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFPercentileCont.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFPercentileCont.java
index 00e17f9..ad61410 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFPercentileCont.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFPercentileCont.java
@@ -18,6 +18,7 @@
 
 package org.apache.hadoop.hive.ql.udf.generic;
 
+import static java.util.Collections.singletonList;
 import static org.apache.hadoop.hive.ql.util.DirectionUtils.DESCENDING_CODE;
 
 import java.io.Serializable;
@@ -88,11 +89,13 @@ public class GenericUDAFPercentileCont extends AbstractGenericUDAFResolver {
     case INT:
     case LONG:
     case VOID:
-      return new PercentileContLongEvaluator();
+      return parameters[1].getCategory() == ObjectInspector.Category.LIST ?
+              new PercentileContLongArrayEvaluator() : new PercentileContLongEvaluator();
     case FLOAT:
     case DOUBLE:
     case DECIMAL:
-      return new PercentileContDoubleEvaluator();
+      return parameters[1].getCategory() == ObjectInspector.Category.LIST ?
+              new PercentileContDoubleArrayEvaluator() : new PercentileContDoubleEvaluator();
     case STRING:
     case TIMESTAMP:
     case VARCHAR:
@@ -155,8 +158,9 @@ public class GenericUDAFPercentileCont extends AbstractGenericUDAFResolver {
   public abstract static class PercentileContEvaluator<T, U> extends GenericUDAFEvaluator {
     PercentileCalculator<U> calc = getCalculator();
 
-    protected PercentileContEvaluator(Comparator<Entry<U, LongWritable>> comparator) {
+    protected PercentileContEvaluator(Comparator<Entry<U, LongWritable>> comparator, Converter converter) {
       this.comparator = comparator;
+      this.converter = converter;
     }
 
     /**
@@ -177,7 +181,7 @@ public class GenericUDAFPercentileCont extends AbstractGenericUDAFResolver {
     protected transient Object[] partialResult;
 
     // FINAL and COMPLETE output
-    protected DoubleWritable result;
+    protected List<DoubleWritable> results;
 
     // PARTIAL2 and FINAL inputs
     protected transient StructObjectInspector soi;
@@ -186,6 +190,7 @@ public class GenericUDAFPercentileCont extends AbstractGenericUDAFResolver {
     protected transient StructField isAscendingField;
 
     private final transient Comparator<Entry<U, LongWritable>> comparator;
+    private final transient Converter converter;
     protected transient boolean isAscending;
 
     public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException {
@@ -205,8 +210,8 @@ public class GenericUDAFPercentileCont extends AbstractGenericUDAFResolver {
 
         return ObjectInspectorFactory.getStandardStructObjectInspector(fname, foi);
       } else { // ...for final result
-        result = new DoubleWritable(0);
-        return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
+        results = null;
+        return converter.getResultObjectInspector();
       }
     }
 
@@ -263,12 +268,9 @@ public class GenericUDAFPercentileCont extends AbstractGenericUDAFResolver {
     @Override
     public void iterate(AggregationBuffer agg, Object[] parameters) throws HiveException {
       PercentileAgg percAgg = (PercentileAgg) agg;
-      Double percentile = ((HiveDecimalWritable) parameters[1]).getHiveDecimal().doubleValue();
 
       if (percAgg.percentiles == null) {
-        validatePercentile(percentile);
-        percAgg.percentiles = new ArrayList<DoubleWritable>(1);
-        percAgg.percentiles.add(new DoubleWritable(percentile));
+        percAgg.percentiles = converter.convertPercentileParameter(parameters[1]);
       }
 
       if (parameters[0] == null) {
@@ -341,15 +343,14 @@ public class GenericUDAFPercentileCont extends AbstractGenericUDAFResolver {
 
       // Accumulate the counts.
       long total = getTotal(entriesList);
-
-      // Initialize the result.
-      if (result == null) {
-        result = new DoubleWritable();
+      if (results == null) {
+        results = new ArrayList<>(percAgg.percentiles.size());
+        for (int i = 0; i < percAgg.percentiles.size(); ++i) {
+          results.add(new DoubleWritable(0));
+        }
       }
-
-      calculatePercentile(percAgg, entriesList, total);
-
-      return result;
+      calculatePercentile(percAgg.percentiles, entriesList, total, results);
+      return converter.convertResults(results);
     }
 
     @Override
@@ -372,22 +373,77 @@ public class GenericUDAFPercentileCont extends AbstractGenericUDAFResolver {
       return total;
     }
 
-    protected void validatePercentile(Double percentile) {
+    public static void validatePercentile(Double percentile) {
       if (percentile < 0.0 || percentile > 1.0) {
         throw new RuntimeException("Percentile value must be within the range of 0 to 1.");
       }
     }
 
-    protected void calculatePercentile(PercentileAgg percAgg,
-        List<Map.Entry<U, LongWritable>> entriesList, long total) {
+    protected List<DoubleWritable> calculatePercentile(List<DoubleWritable> percentiles,
+        List<Map.Entry<U, LongWritable>> entriesList, long total, List<DoubleWritable> results) {
       // maxPosition is the 1.0 percentile
       long maxPosition = total - 1;
-      double position = maxPosition * percAgg.percentiles.get(0).get();
-      result.set(calc.getPercentile(entriesList, position));
+      for (int i = 0; i < percentiles.size(); ++i) {
+        DoubleWritable percentile = percentiles.get(i);
+        double position = maxPosition * percentile.get();
+        results.get(i).set(calc.getPercentile(entriesList, position));
+      }
+
+      return results;
+    }
+
+  }
+
+  private interface Converter {
+    List<DoubleWritable> convertPercentileParameter(Object parameter);
+    Object convertResults(List<DoubleWritable> results);
+    ObjectInspector getResultObjectInspector();
+  }
+
+  private static class PrimitiveConverter implements Converter {
+
+    @Override
+    public List<DoubleWritable> convertPercentileParameter(Object parameter) {
+      Double percentile = ((HiveDecimalWritable) parameter).getHiveDecimal().doubleValue();
+      PercentileContEvaluator.validatePercentile(percentile);
+      return singletonList(new DoubleWritable(percentile));
+    }
+
+    @Override
+    public Object convertResults(List<DoubleWritable> results) {
+      return results.get(0);
     }
 
+    public ObjectInspector getResultObjectInspector() {
+      return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
+    }
   }
 
+  private static class ArrayConverter implements Converter {
+    public List<DoubleWritable> convertPercentileParameter(Object parameter) {
+      ArrayList<HiveDecimalWritable> percentilesParameter = (ArrayList<HiveDecimalWritable>) parameter;
+      List<DoubleWritable> percentileList = new ArrayList<>(percentilesParameter.size());
+      for (HiveDecimalWritable hiveDecimalWritable : percentilesParameter) {
+        Double percentile = hiveDecimalWritable.getHiveDecimal().doubleValue();
+        PercentileContEvaluator.validatePercentile(percentile);
+        percentileList.add(new DoubleWritable(percentile));
+      }
+      return percentileList;
+    }
+
+    @Override
+    public Object convertResults(List<DoubleWritable> results) {
+      return results;
+    }
+
+    @Override
+    public ObjectInspector getResultObjectInspector() {
+      return ObjectInspectorFactory.getStandardListObjectInspector(
+              PrimitiveObjectInspectorFactory.writableDoubleObjectInspector);
+    }
+  }
+
+
   /**
    * The evaluator for percentile computation based on long.
    */
@@ -395,7 +451,11 @@ public class GenericUDAFPercentileCont extends AbstractGenericUDAFResolver {
       extends PercentileContEvaluator<Long, LongWritable> {
 
     public PercentileContLongEvaluator() {
-      super(new LongComparator());
+      this(new PrimitiveConverter());
+    }
+
+    public PercentileContLongEvaluator(Converter converter) {
+      super(new LongComparator(), converter);
     }
 
     protected ArrayList<ObjectInspector> getPartialInspectors() {
@@ -429,12 +489,25 @@ public class GenericUDAFPercentileCont extends AbstractGenericUDAFResolver {
   }
 
   /**
+   * The evaluator for percentile computation based on array of longs.
+   */
+  public static class PercentileContLongArrayEvaluator extends PercentileContLongEvaluator {
+    public PercentileContLongArrayEvaluator() {
+      super(new ArrayConverter());
+    }
+  }
+
+  /**
    * The evaluator for percentile computation based on double.
    */
   public static class PercentileContDoubleEvaluator
       extends PercentileContEvaluator<Double, DoubleWritable> {
     public PercentileContDoubleEvaluator() {
-      super(new DoubleComparator());
+      this(new PrimitiveConverter());
+    }
+
+    public PercentileContDoubleEvaluator(Converter converter) {
+      super(new DoubleComparator(), converter);
     }
 
     @Override
@@ -471,6 +544,15 @@ public class GenericUDAFPercentileCont extends AbstractGenericUDAFResolver {
   }
 
   /**
+   * The evaluator for percentile computation based on array of doubles.
+   */
+  public static class PercentileContDoubleArrayEvaluator extends PercentileContDoubleEvaluator {
+    public PercentileContDoubleArrayEvaluator() {
+      super(new ArrayConverter());
+    }
+  }
+
+  /**
    * continuous percentile calculators
    */
   public static class PercentileContLongCalculator implements PercentileCalculator<LongWritable> {
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFPercentileDisc.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFPercentileDisc.java
index 21580f7..c8d3c12 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFPercentileDisc.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFPercentileDisc.java
@@ -26,6 +26,7 @@ import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
 import org.apache.hadoop.hive.ql.exec.WindowFunctionDescription;
 import org.apache.hadoop.hive.ql.parse.SemanticException;
 import org.apache.hadoop.hive.serde2.io.DoubleWritable;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
 import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo;
 import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo;
 import org.apache.hadoop.io.LongWritable;
@@ -53,11 +54,13 @@ public class GenericUDAFPercentileDisc extends GenericUDAFPercentileCont {
     case INT:
     case LONG:
     case VOID:
-      return new PercentileDiscLongEvaluator();
+      return parameters[1].getCategory() == ObjectInspector.Category.LIST ?
+              new PercentileDiscLongArrayEvaluator() : new PercentileDiscLongEvaluator();
     case FLOAT:
     case DOUBLE:
     case DECIMAL:
-      return new PercentileDiscDoubleEvaluator();
+      return parameters[1].getCategory() == ObjectInspector.Category.LIST ?
+              new PercentileDiscDoubleArrayEvaluator() : new PercentileDiscDoubleEvaluator();
     case STRING:
     case TIMESTAMP:
     case VARCHAR:
@@ -74,6 +77,22 @@ public class GenericUDAFPercentileDisc extends GenericUDAFPercentileCont {
    * The evaluator for discrete percentile computation based on long.
    */
   public static class PercentileDiscLongEvaluator extends PercentileContLongEvaluator {
+    public PercentileDiscLongEvaluator() {
+    }
+
+    @Override
+    protected PercentileCalculator<LongWritable> getCalculator() {
+      return new PercentileDiscLongCalculator();
+    }
+  }
+
+  /**
+   * The evaluator for discrete percentile computation based on array of longs.
+   */
+  public static class PercentileDiscLongArrayEvaluator extends PercentileContLongArrayEvaluator {
+    public PercentileDiscLongArrayEvaluator() {
+    }
+
     @Override
     protected PercentileCalculator<LongWritable> getCalculator() {
       return new PercentileDiscLongCalculator();
@@ -84,6 +103,24 @@ public class GenericUDAFPercentileDisc extends GenericUDAFPercentileCont {
    * The evaluator for discrete percentile computation based on double.
    */
   public static class PercentileDiscDoubleEvaluator extends PercentileContDoubleEvaluator {
+    public PercentileDiscDoubleEvaluator() {
+      super();
+    }
+
+    @Override
+    protected PercentileCalculator<DoubleWritable> getCalculator() {
+      return new PercentileDiscDoubleCalculator();
+    }
+  }
+
+  /**
+   * The evaluator for discrete percentile computation based on array of doubles.
+   */
+  public static class PercentileDiscDoubleArrayEvaluator extends PercentileContDoubleArrayEvaluator {
+    public PercentileDiscDoubleArrayEvaluator() {
+      super();
+    }
+
     @Override
     protected PercentileCalculator<DoubleWritable> getCalculator() {
       return new PercentileDiscDoubleCalculator();
diff --git a/ql/src/test/queries/clientpositive/udaf_percentile_cont.q b/ql/src/test/queries/clientpositive/udaf_percentile_cont.q
index 7a1ac5c..db54eaa 100644
--- a/ql/src/test/queries/clientpositive/udaf_percentile_cont.q
+++ b/ql/src/test/queries/clientpositive/udaf_percentile_cont.q
@@ -12,7 +12,8 @@ SELECT CAST(key AS INT) DIV 10,
        percentile_cont(CAST(substr(value, 5) AS INT), 0.0),
        percentile_cont(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_cont(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE)),
-       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_cont(array(0.0, 0.5, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10;
 
@@ -24,7 +25,8 @@ SELECT CAST(key AS INT) DIV 10,
        percentile_cont(CAST(substr(value, 5) AS INT), 0.0),
        percentile_cont(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_cont(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE)),
-       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_cont(array(0.0, 0.1, 0.5, 0.8, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10;
 
@@ -37,7 +39,8 @@ SELECT CAST(key AS INT) DIV 10,
        percentile_cont(CAST(substr(value, 5) AS INT), 0.0),
        percentile_cont(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_cont(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE)),
-       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_cont(array(0.5, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10;
 
@@ -49,7 +52,8 @@ SELECT CAST(key AS INT) DIV 10,
        percentile_cont(CAST(substr(value, 5) AS INT), 0.0),
        percentile_cont(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_cont(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE)),
-       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_cont(array(0.0, 0.5, 0.7, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10;
 
@@ -107,4 +111,4 @@ percentile_cont(0.2) WITHIN GROUP (ORDER BY value DESC NULLS FIRST),
 percentile_cont(0.2) WITHIN GROUP (ORDER BY value DESC NULLS LAST)
 FROM t_test;
 
-DROP TABLE t_test;
\ No newline at end of file
+DROP TABLE t_test;
diff --git a/ql/src/test/queries/clientpositive/udaf_percentile_disc.q b/ql/src/test/queries/clientpositive/udaf_percentile_disc.q
index 6d93b34..80a33ab 100644
--- a/ql/src/test/queries/clientpositive/udaf_percentile_disc.q
+++ b/ql/src/test/queries/clientpositive/udaf_percentile_disc.q
@@ -12,7 +12,8 @@ SELECT CAST(key AS INT) DIV 10,
        percentile_disc(CAST(substr(value, 5) AS INT), 0.0),
        percentile_disc(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_disc(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS INT)),
-       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_disc(array(0.0, 0.5, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10;
 
@@ -24,7 +25,8 @@ SELECT CAST(key AS INT) DIV 10,
        percentile_disc(CAST(substr(value, 5) AS INT), 0.0),
        percentile_disc(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_disc(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS INT)),
-       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_disc(array(0.0, 0.5, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10;
 
@@ -37,7 +39,8 @@ SELECT CAST(key AS INT) DIV 10,
        percentile_disc(CAST(substr(value, 5) AS INT), 0.0),
        percentile_disc(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_disc(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS INT)),
-       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_disc(array(0.0, 0.5, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10;
 
@@ -49,7 +52,8 @@ SELECT CAST(key AS INT) DIV 10,
        percentile_disc(CAST(substr(value, 5) AS INT), 0.0),
        percentile_disc(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_disc(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS INT)),
-       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_disc(array(0.0, 0.5, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10;
 
@@ -108,4 +112,4 @@ percentile_disc(0.2) WITHIN GROUP (ORDER BY value DESC NULLS FIRST),
 percentile_disc(0.2) WITHIN GROUP (ORDER BY value DESC NULLS LAST)
 FROM t_test;
 
-DROP TABLE t_test;
\ No newline at end of file
+DROP TABLE t_test;
diff --git a/ql/src/test/results/clientpositive/udaf_percentile_cont.q.out b/ql/src/test/results/clientpositive/udaf_percentile_cont.q.out
index cddd908..f12cb6c 100644
--- a/ql/src/test/results/clientpositive/udaf_percentile_cont.q.out
+++ b/ql/src/test/results/clientpositive/udaf_percentile_cont.q.out
@@ -14,7 +14,8 @@ PREHOOK: query: SELECT CAST(key AS INT) DIV 10,
        percentile_cont(CAST(substr(value, 5) AS INT), 0.0),
        percentile_cont(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_cont(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE)),
-       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_cont(array(0.0, 0.5, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10
 PREHOOK: type: QUERY
@@ -24,67 +25,69 @@ POSTHOOK: query: SELECT CAST(key AS INT) DIV 10,
        percentile_cont(CAST(substr(value, 5) AS INT), 0.0),
        percentile_cont(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_cont(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE)),
-       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_cont(array(0.0, 0.5, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 #### A masked pattern was here ####
-0	0.0	4.5	4.5	9.0
-1	10.0	15.0	15.0	19.0
-10	100.0	103.0	103.0	105.0
-11	111.0	117.0	117.0	119.0
-12	120.0	127.0	127.0	129.0
-13	131.0	137.0	137.0	138.0
-14	143.0	146.0	146.0	149.0
-15	150.0	154.0	154.0	158.0
-16	160.0	166.5	166.5	169.0
-17	170.0	175.0	175.0	179.0
-18	180.0	186.5	186.5	189.0
-19	190.0	194.5	194.5	199.0
-2	20.0	26.0	26.0	28.0
-20	200.0	205.0	205.0	209.0
-21	213.0	216.5	216.5	219.0
-22	221.0	224.0	224.0	229.0
-23	230.0	234.0	234.0	239.0
-24	241.0	244.0	244.0	249.0
-25	252.0	256.0	256.0	258.0
-26	260.0	264.0	264.0	266.0
-27	272.0	275.0	275.0	278.0
-28	280.0	283.5	283.5	289.0
-29	291.0	297.0	297.0	298.0
-3	30.0	35.0	35.0	37.0
-30	302.0	307.0	307.0	309.0
-31	310.0	316.0	316.0	318.0
-32	321.0	324.0	324.0	327.0
-33	331.0	333.0	333.0	339.0
-34	341.0	345.0	345.0	348.0
-35	351.0	353.0	353.0	356.0
-36	360.0	367.0	367.0	369.0
-37	373.0	376.0	376.0	379.0
-38	382.0	384.0	384.0	389.0
-39	392.0	396.0	396.0	399.0
-4	41.0	42.5	42.5	47.0
-40	400.0	403.5	403.5	409.0
-41	411.0	415.5	415.5	419.0
-42	421.0	425.5	425.5	429.0
-43	430.0	435.0	435.0	439.0
-44	443.0	446.0	446.0	449.0
-45	452.0	455.0	455.0	459.0
-46	460.0	467.5	467.5	469.0
-47	470.0	477.0	477.0	479.0
-48	480.0	484.0	484.0	489.0
-49	490.0	494.5	494.5	498.0
-5	51.0	54.0	54.0	58.0
-6	64.0	66.5	66.5	69.0
-7	70.0	73.0	73.0	78.0
-8	80.0	84.0	84.0	87.0
-9	90.0	95.0	95.0	98.0
+0	0.0	4.5	4.5	9.0	[0.0,4.5,9.0]
+1	10.0	15.0	15.0	19.0	[10.0,15.0,19.0]
+10	100.0	103.0	103.0	105.0	[100.0,103.0,105.0]
+11	111.0	117.0	117.0	119.0	[111.0,117.0,119.0]
+12	120.0	127.0	127.0	129.0	[120.0,127.0,129.0]
+13	131.0	137.0	137.0	138.0	[131.0,137.0,138.0]
+14	143.0	146.0	146.0	149.0	[143.0,146.0,149.0]
+15	150.0	154.0	154.0	158.0	[150.0,154.0,158.0]
+16	160.0	166.5	166.5	169.0	[160.0,166.5,169.0]
+17	170.0	175.0	175.0	179.0	[170.0,175.0,179.0]
+18	180.0	186.5	186.5	189.0	[180.0,186.5,189.0]
+19	190.0	194.5	194.5	199.0	[190.0,194.5,199.0]
+2	20.0	26.0	26.0	28.0	[20.0,26.0,28.0]
+20	200.0	205.0	205.0	209.0	[200.0,205.0,209.0]
+21	213.0	216.5	216.5	219.0	[213.0,216.5,219.0]
+22	221.0	224.0	224.0	229.0	[221.0,224.0,229.0]
+23	230.0	234.0	234.0	239.0	[230.0,234.0,239.0]
+24	241.0	244.0	244.0	249.0	[241.0,244.0,249.0]
+25	252.0	256.0	256.0	258.0	[252.0,256.0,258.0]
+26	260.0	264.0	264.0	266.0	[260.0,264.0,266.0]
+27	272.0	275.0	275.0	278.0	[272.0,275.0,278.0]
+28	280.0	283.5	283.5	289.0	[280.0,283.5,289.0]
+29	291.0	297.0	297.0	298.0	[291.0,297.0,298.0]
+3	30.0	35.0	35.0	37.0	[30.0,35.0,37.0]
+30	302.0	307.0	307.0	309.0	[302.0,307.0,309.0]
+31	310.0	316.0	316.0	318.0	[310.0,316.0,318.0]
+32	321.0	324.0	324.0	327.0	[321.0,324.0,327.0]
+33	331.0	333.0	333.0	339.0	[331.0,333.0,339.0]
+34	341.0	345.0	345.0	348.0	[341.0,345.0,348.0]
+35	351.0	353.0	353.0	356.0	[351.0,353.0,356.0]
+36	360.0	367.0	367.0	369.0	[360.0,367.0,369.0]
+37	373.0	376.0	376.0	379.0	[373.0,376.0,379.0]
+38	382.0	384.0	384.0	389.0	[382.0,384.0,389.0]
+39	392.0	396.0	396.0	399.0	[392.0,396.0,399.0]
+4	41.0	42.5	42.5	47.0	[41.0,42.5,47.0]
+40	400.0	403.5	403.5	409.0	[400.0,403.5,409.0]
+41	411.0	415.5	415.5	419.0	[411.0,415.5,419.0]
+42	421.0	425.5	425.5	429.0	[421.0,425.5,429.0]
+43	430.0	435.0	435.0	439.0	[430.0,435.0,439.0]
+44	443.0	446.0	446.0	449.0	[443.0,446.0,449.0]
+45	452.0	455.0	455.0	459.0	[452.0,455.0,459.0]
+46	460.0	467.5	467.5	469.0	[460.0,467.5,469.0]
+47	470.0	477.0	477.0	479.0	[470.0,477.0,479.0]
+48	480.0	484.0	484.0	489.0	[480.0,484.0,489.0]
+49	490.0	494.5	494.5	498.0	[490.0,494.5,498.0]
+5	51.0	54.0	54.0	58.0	[51.0,54.0,58.0]
+6	64.0	66.5	66.5	69.0	[64.0,66.5,69.0]
+7	70.0	73.0	73.0	78.0	[70.0,73.0,78.0]
+8	80.0	84.0	84.0	87.0	[80.0,84.0,87.0]
+9	90.0	95.0	95.0	98.0	[90.0,95.0,98.0]
 PREHOOK: query: SELECT CAST(key AS INT) DIV 10,
        percentile_cont(CAST(substr(value, 5) AS INT), 0.0),
        percentile_cont(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_cont(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE)),
-       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_cont(array(0.0, 0.1, 0.5, 0.8, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10
 PREHOOK: type: QUERY
@@ -94,67 +97,69 @@ POSTHOOK: query: SELECT CAST(key AS INT) DIV 10,
        percentile_cont(CAST(substr(value, 5) AS INT), 0.0),
        percentile_cont(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_cont(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE)),
-       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_cont(array(0.0, 0.1, 0.5, 0.8, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 #### A masked pattern was here ####
-0	0.0	4.5	4.5	9.0
-1	10.0	15.0	15.0	19.0
-10	100.0	103.0	103.0	105.0
-11	111.0	117.0	117.0	119.0
-12	120.0	127.0	127.0	129.0
-13	131.0	137.0	137.0	138.0
-14	143.0	146.0	146.0	149.0
-15	150.0	154.0	154.0	158.0
-16	160.0	166.5	166.5	169.0
-17	170.0	175.0	175.0	179.0
-18	180.0	186.5	186.5	189.0
-19	190.0	194.5	194.5	199.0
-2	20.0	26.0	26.0	28.0
-20	200.0	205.0	205.0	209.0
-21	213.0	216.5	216.5	219.0
-22	221.0	224.0	224.0	229.0
-23	230.0	234.0	234.0	239.0
-24	241.0	244.0	244.0	249.0
-25	252.0	256.0	256.0	258.0
-26	260.0	264.0	264.0	266.0
-27	272.0	275.0	275.0	278.0
-28	280.0	283.5	283.5	289.0
-29	291.0	297.0	297.0	298.0
-3	30.0	35.0	35.0	37.0
-30	302.0	307.0	307.0	309.0
-31	310.0	316.0	316.0	318.0
-32	321.0	324.0	324.0	327.0
-33	331.0	333.0	333.0	339.0
-34	341.0	345.0	345.0	348.0
-35	351.0	353.0	353.0	356.0
-36	360.0	367.0	367.0	369.0
-37	373.0	376.0	376.0	379.0
-38	382.0	384.0	384.0	389.0
-39	392.0	396.0	396.0	399.0
-4	41.0	42.5	42.5	47.0
-40	400.0	403.5	403.5	409.0
-41	411.0	415.5	415.5	419.0
-42	421.0	425.5	425.5	429.0
-43	430.0	435.0	435.0	439.0
-44	443.0	446.0	446.0	449.0
-45	452.0	455.0	455.0	459.0
-46	460.0	467.5	467.5	469.0
-47	470.0	477.0	477.0	479.0
-48	480.0	484.0	484.0	489.0
-49	490.0	494.5	494.5	498.0
-5	51.0	54.0	54.0	58.0
-6	64.0	66.5	66.5	69.0
-7	70.0	73.0	73.0	78.0
-8	80.0	84.0	84.0	87.0
-9	90.0	95.0	95.0	98.0
+0	0.0	4.5	4.5	9.0	[0.0,0.0,4.5,5.6000000000000005,9.0]
+1	10.0	15.0	15.0	19.0	[10.0,10.9,15.0,18.0,19.0]
+10	100.0	103.0	103.0	105.0	[100.0,100.0,103.0,104.0,105.0]
+11	111.0	117.0	117.0	119.0	[111.0,112.8,117.0,119.0,119.0]
+12	120.0	127.0	127.0	129.0	[120.0,120.0,127.0,128.2,129.0]
+13	131.0	137.0	137.0	138.0	[131.0,133.0,137.0,138.0,138.0]
+14	143.0	146.0	146.0	149.0	[143.0,144.0,146.0,149.0,149.0]
+15	150.0	154.0	154.0	158.0	[150.0,151.4,154.0,156.60000000000002,158.0]
+16	160.0	166.5	166.5	169.0	[160.0,162.5,166.5,169.0,169.0]
+17	170.0	175.0	175.0	179.0	[170.0,172.0,175.0,177.60000000000002,179.0]
+18	180.0	186.5	186.5	189.0	[180.0,180.7,186.5,187.0,189.0]
+19	190.0	194.5	194.5	199.0	[190.0,191.0,194.5,197.0,199.0]
+2	20.0	26.0	26.0	28.0	[20.0,22.4,26.0,26.8,28.0]
+20	200.0	205.0	205.0	209.0	[200.0,200.39999999999998,205.0,208.0,209.0]
+21	213.0	216.5	216.5	219.0	[213.0,213.0,216.5,218.2,219.0]
+22	221.0	224.0	224.0	229.0	[221.0,221.0,224.0,228.0,229.0]
+23	230.0	234.0	234.0	239.0	[230.0,230.0,234.0,238.0,239.0]
+24	241.0	244.0	244.0	249.0	[241.0,241.6,244.0,247.8,249.0]
+25	252.0	256.0	256.0	258.0	[252.0,253.8,256.0,256.8,258.0]
+26	260.0	264.0	264.0	266.0	[260.0,261.0,264.0,265.0,266.0]
+27	272.0	275.0	275.0	278.0	[272.0,272.20000000000005,275.0,277.0,278.0]
+28	280.0	283.5	283.5	289.0	[280.0,280.3,283.5,287.4,289.0]
+29	291.0	297.0	297.0	298.0	[291.0,291.5,297.0,298.0,298.0]
+3	30.0	35.0	35.0	37.0	[30.0,32.1,35.0,36.2,37.0]
+30	302.0	307.0	307.0	309.0	[302.0,304.1,307.0,308.6,309.0]
+31	310.0	316.0	316.0	318.0	[310.0,311.0,316.0,317.6,318.0]
+32	321.0	324.0	324.0	327.0	[321.0,321.0,324.0,327.0,327.0]
+33	331.0	333.0	333.0	339.0	[331.0,331.0,333.0,336.8,339.0]
+34	341.0	345.0	345.0	348.0	[341.0,342.0,345.0,348.0,348.0]
+35	351.0	353.0	353.0	356.0	[351.0,351.6,353.0,354.2,356.0]
+36	360.0	367.0	367.0	369.0	[360.0,362.0,367.0,369.0,369.0]
+37	373.0	376.0	376.0	379.0	[373.0,373.5,376.0,378.0,379.0]
+38	382.0	384.0	384.0	389.0	[382.0,382.0,384.0,385.6,389.0]
+39	392.0	396.0	396.0	399.0	[392.0,393.1,396.0,397.0,399.0]
+4	41.0	42.5	42.5	47.0	[41.0,41.5,42.5,44.0,47.0]
+40	400.0	403.5	403.5	409.0	[400.0,401.0,403.5,406.2,409.0]
+41	411.0	415.5	415.5	419.0	[411.0,412.79999999999995,415.5,417.2,419.0]
+42	421.0	425.5	425.5	429.0	[421.0,422.5,425.5,429.0,429.0]
+43	430.0	435.0	435.0	439.0	[430.0,430.0,435.0,438.0,439.0]
+44	443.0	446.0	446.0	449.0	[443.0,443.40000000000003,446.0,448.2,449.0]
+45	452.0	455.0	455.0	459.0	[452.0,453.0,455.0,458.0,459.0]
+46	460.0	467.5	467.5	469.0	[460.0,462.0,467.5,469.0,469.0]
+47	470.0	477.0	477.0	479.0	[470.0,471.20000000000005,477.0,478.0,479.0]
+48	480.0	484.0	484.0	489.0	[480.0,480.0,484.0,489.0,489.0]
+49	490.0	494.5	494.5	498.0	[490.0,491.1,494.5,497.8,498.0]
+5	51.0	54.0	54.0	58.0	[51.0,51.0,54.0,57.8,58.0]
+6	64.0	66.5	66.5	69.0	[64.0,64.5,66.5,67.0,69.0]
+7	70.0	73.0	73.0	78.0	[70.0,70.0,73.0,76.19999999999999,78.0]
+8	80.0	84.0	84.0	87.0	[80.0,81.60000000000001,84.0,85.4,87.0]
+9	90.0	95.0	95.0	98.0	[90.0,90.0,95.0,97.0,98.0]
 PREHOOK: query: SELECT CAST(key AS INT) DIV 10,
        percentile_cont(CAST(substr(value, 5) AS INT), 0.0),
        percentile_cont(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_cont(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE)),
-       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_cont(array(0.5, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10
 PREHOOK: type: QUERY
@@ -164,67 +169,69 @@ POSTHOOK: query: SELECT CAST(key AS INT) DIV 10,
        percentile_cont(CAST(substr(value, 5) AS INT), 0.0),
        percentile_cont(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_cont(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE)),
-       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_cont(array(0.5, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 #### A masked pattern was here ####
-0	0.0	4.5	4.5	9.0
-1	10.0	15.0	15.0	19.0
-10	100.0	103.0	103.0	105.0
-11	111.0	117.0	117.0	119.0
-12	120.0	127.0	127.0	129.0
-13	131.0	137.0	137.0	138.0
-14	143.0	146.0	146.0	149.0
-15	150.0	154.0	154.0	158.0
-16	160.0	166.5	166.5	169.0
-17	170.0	175.0	175.0	179.0
-18	180.0	186.5	186.5	189.0
-19	190.0	194.5	194.5	199.0
-2	20.0	26.0	26.0	28.0
-20	200.0	205.0	205.0	209.0
-21	213.0	216.5	216.5	219.0
-22	221.0	224.0	224.0	229.0
-23	230.0	234.0	234.0	239.0
-24	241.0	244.0	244.0	249.0
-25	252.0	256.0	256.0	258.0
-26	260.0	264.0	264.0	266.0
-27	272.0	275.0	275.0	278.0
-28	280.0	283.5	283.5	289.0
-29	291.0	297.0	297.0	298.0
-3	30.0	35.0	35.0	37.0
-30	302.0	307.0	307.0	309.0
-31	310.0	316.0	316.0	318.0
-32	321.0	324.0	324.0	327.0
-33	331.0	333.0	333.0	339.0
-34	341.0	345.0	345.0	348.0
-35	351.0	353.0	353.0	356.0
-36	360.0	367.0	367.0	369.0
-37	373.0	376.0	376.0	379.0
-38	382.0	384.0	384.0	389.0
-39	392.0	396.0	396.0	399.0
-4	41.0	42.5	42.5	47.0
-40	400.0	403.5	403.5	409.0
-41	411.0	415.5	415.5	419.0
-42	421.0	425.5	425.5	429.0
-43	430.0	435.0	435.0	439.0
-44	443.0	446.0	446.0	449.0
-45	452.0	455.0	455.0	459.0
-46	460.0	467.5	467.5	469.0
-47	470.0	477.0	477.0	479.0
-48	480.0	484.0	484.0	489.0
-49	490.0	494.5	494.5	498.0
-5	51.0	54.0	54.0	58.0
-6	64.0	66.5	66.5	69.0
-7	70.0	73.0	73.0	78.0
-8	80.0	84.0	84.0	87.0
-9	90.0	95.0	95.0	98.0
+0	0.0	4.5	4.5	9.0	[4.5,9.0]
+1	10.0	15.0	15.0	19.0	[15.0,19.0]
+10	100.0	103.0	103.0	105.0	[103.0,105.0]
+11	111.0	117.0	117.0	119.0	[117.0,119.0]
+12	120.0	127.0	127.0	129.0	[127.0,129.0]
+13	131.0	137.0	137.0	138.0	[137.0,138.0]
+14	143.0	146.0	146.0	149.0	[146.0,149.0]
+15	150.0	154.0	154.0	158.0	[154.0,158.0]
+16	160.0	166.5	166.5	169.0	[166.5,169.0]
+17	170.0	175.0	175.0	179.0	[175.0,179.0]
+18	180.0	186.5	186.5	189.0	[186.5,189.0]
+19	190.0	194.5	194.5	199.0	[194.5,199.0]
+2	20.0	26.0	26.0	28.0	[26.0,28.0]
+20	200.0	205.0	205.0	209.0	[205.0,209.0]
+21	213.0	216.5	216.5	219.0	[216.5,219.0]
+22	221.0	224.0	224.0	229.0	[224.0,229.0]
+23	230.0	234.0	234.0	239.0	[234.0,239.0]
+24	241.0	244.0	244.0	249.0	[244.0,249.0]
+25	252.0	256.0	256.0	258.0	[256.0,258.0]
+26	260.0	264.0	264.0	266.0	[264.0,266.0]
+27	272.0	275.0	275.0	278.0	[275.0,278.0]
+28	280.0	283.5	283.5	289.0	[283.5,289.0]
+29	291.0	297.0	297.0	298.0	[297.0,298.0]
+3	30.0	35.0	35.0	37.0	[35.0,37.0]
+30	302.0	307.0	307.0	309.0	[307.0,309.0]
+31	310.0	316.0	316.0	318.0	[316.0,318.0]
+32	321.0	324.0	324.0	327.0	[324.0,327.0]
+33	331.0	333.0	333.0	339.0	[333.0,339.0]
+34	341.0	345.0	345.0	348.0	[345.0,348.0]
+35	351.0	353.0	353.0	356.0	[353.0,356.0]
+36	360.0	367.0	367.0	369.0	[367.0,369.0]
+37	373.0	376.0	376.0	379.0	[376.0,379.0]
+38	382.0	384.0	384.0	389.0	[384.0,389.0]
+39	392.0	396.0	396.0	399.0	[396.0,399.0]
+4	41.0	42.5	42.5	47.0	[42.5,47.0]
+40	400.0	403.5	403.5	409.0	[403.5,409.0]
+41	411.0	415.5	415.5	419.0	[415.5,419.0]
+42	421.0	425.5	425.5	429.0	[425.5,429.0]
+43	430.0	435.0	435.0	439.0	[435.0,439.0]
+44	443.0	446.0	446.0	449.0	[446.0,449.0]
+45	452.0	455.0	455.0	459.0	[455.0,459.0]
+46	460.0	467.5	467.5	469.0	[467.5,469.0]
+47	470.0	477.0	477.0	479.0	[477.0,479.0]
+48	480.0	484.0	484.0	489.0	[484.0,489.0]
+49	490.0	494.5	494.5	498.0	[494.5,498.0]
+5	51.0	54.0	54.0	58.0	[54.0,58.0]
+6	64.0	66.5	66.5	69.0	[66.5,69.0]
+7	70.0	73.0	73.0	78.0	[73.0,78.0]
+8	80.0	84.0	84.0	87.0	[84.0,87.0]
+9	90.0	95.0	95.0	98.0	[95.0,98.0]
 PREHOOK: query: SELECT CAST(key AS INT) DIV 10,
        percentile_cont(CAST(substr(value, 5) AS INT), 0.0),
        percentile_cont(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_cont(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE)),
-       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_cont(array(0.0, 0.5, 0.7, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10
 PREHOOK: type: QUERY
@@ -234,62 +241,63 @@ POSTHOOK: query: SELECT CAST(key AS INT) DIV 10,
        percentile_cont(CAST(substr(value, 5) AS INT), 0.0),
        percentile_cont(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_cont(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE)),
-       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_cont(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_cont(array(0.0, 0.5, 0.7, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 #### A masked pattern was here ####
-0	0.0	4.5	4.5	9.0
-1	10.0	15.0	15.0	19.0
-10	100.0	103.0	103.0	105.0
-11	111.0	117.0	117.0	119.0
-12	120.0	127.0	127.0	129.0
-13	131.0	137.0	137.0	138.0
-14	143.0	146.0	146.0	149.0
-15	150.0	154.0	154.0	158.0
-16	160.0	166.5	166.5	169.0
-17	170.0	175.0	175.0	179.0
-18	180.0	186.5	186.5	189.0
-19	190.0	194.5	194.5	199.0
-2	20.0	26.0	26.0	28.0
-20	200.0	205.0	205.0	209.0
-21	213.0	216.5	216.5	219.0
-22	221.0	224.0	224.0	229.0
-23	230.0	234.0	234.0	239.0
-24	241.0	244.0	244.0	249.0
-25	252.0	256.0	256.0	258.0
-26	260.0	264.0	264.0	266.0
-27	272.0	275.0	275.0	278.0
-28	280.0	283.5	283.5	289.0
-29	291.0	297.0	297.0	298.0
-3	30.0	35.0	35.0	37.0
-30	302.0	307.0	307.0	309.0
-31	310.0	316.0	316.0	318.0
-32	321.0	324.0	324.0	327.0
-33	331.0	333.0	333.0	339.0
-34	341.0	345.0	345.0	348.0
-35	351.0	353.0	353.0	356.0
-36	360.0	367.0	367.0	369.0
-37	373.0	376.0	376.0	379.0
-38	382.0	384.0	384.0	389.0
-39	392.0	396.0	396.0	399.0
-4	41.0	42.5	42.5	47.0
-40	400.0	403.5	403.5	409.0
-41	411.0	415.5	415.5	419.0
-42	421.0	425.5	425.5	429.0
-43	430.0	435.0	435.0	439.0
-44	443.0	446.0	446.0	449.0
-45	452.0	455.0	455.0	459.0
-46	460.0	467.5	467.5	469.0
-47	470.0	477.0	477.0	479.0
-48	480.0	484.0	484.0	489.0
-49	490.0	494.5	494.5	498.0
-5	51.0	54.0	54.0	58.0
-6	64.0	66.5	66.5	69.0
-7	70.0	73.0	73.0	78.0
-8	80.0	84.0	84.0	87.0
-9	90.0	95.0	95.0	98.0
+0	0.0	4.5	4.5	9.0	[0.0,4.5,5.0,9.0]
+1	10.0	15.0	15.0	19.0	[10.0,15.0,17.299999999999997,19.0]
+10	100.0	103.0	103.0	105.0	[100.0,103.0,104.0,105.0]
+11	111.0	117.0	117.0	119.0	[111.0,117.0,118.30000000000001,119.0]
+12	120.0	127.0	127.0	129.0	[120.0,127.0,128.0,129.0]
+13	131.0	137.0	137.0	138.0	[131.0,137.0,138.0,138.0]
+14	143.0	146.0	146.0	149.0	[143.0,146.0,147.5,149.0]
+15	150.0	154.0	154.0	158.0	[150.0,154.0,155.9,158.0]
+16	160.0	166.5	166.5	169.0	[160.0,166.5,167.5,169.0]
+17	170.0	175.0	175.0	179.0	[170.0,175.0,176.4,179.0]
+18	180.0	186.5	186.5	189.0	[180.0,186.5,187.0,189.0]
+19	190.0	194.5	194.5	199.0	[190.0,194.5,196.5,199.0]
+2	20.0	26.0	26.0	28.0	[20.0,26.0,26.2,28.0]
+20	200.0	205.0	205.0	209.0	[200.0,205.0,207.8,209.0]
+21	213.0	216.5	216.5	219.0	[213.0,216.5,217.3,219.0]
+22	221.0	224.0	224.0	229.0	[221.0,224.0,226.0,229.0]
+23	230.0	234.0	234.0	239.0	[230.0,234.0,237.10000000000002,239.0]
+24	241.0	244.0	244.0	249.0	[241.0,244.0,247.2,249.0]
+25	252.0	256.0	256.0	258.0	[252.0,256.0,256.2,258.0]
+26	260.0	264.0	264.0	266.0	[260.0,264.0,265.0,266.0]
+27	272.0	275.0	275.0	278.0	[272.0,275.0,277.0,278.0]
+28	280.0	283.5	283.5	289.0	[280.0,283.5,286.09999999999997,289.0]
+29	291.0	297.0	297.0	298.0	[291.0,297.0,298.0,298.0]
+3	30.0	35.0	35.0	37.0	[30.0,35.0,35.0,37.0]
+30	302.0	307.0	307.0	309.0	[302.0,307.0,307.9,309.0]
+31	310.0	316.0	316.0	318.0	[310.0,316.0,317.0,318.0]
+32	321.0	324.0	324.0	327.0	[321.0,324.0,325.6,327.0]
+33	331.0	333.0	333.0	339.0	[331.0,333.0,335.6,339.0]
+34	341.0	345.0	345.0	348.0	[341.0,345.0,348.0,348.0]
+35	351.0	353.0	353.0	356.0	[351.0,353.0,353.29999999999995,356.0]
+36	360.0	367.0	367.0	369.0	[360.0,367.0,368.0,369.0]
+37	373.0	376.0	376.0	379.0	[373.0,376.0,377.5,379.0]
+38	382.0	384.0	384.0	389.0	[382.0,384.0,384.4,389.0]
+39	392.0	396.0	396.0	399.0	[392.0,396.0,396.7,399.0]
+4	41.0	42.5	42.5	47.0	[41.0,42.5,43.5,47.0]
+40	400.0	403.5	403.5	409.0	[400.0,403.5,406.0,409.0]
+41	411.0	415.5	415.5	419.0	[411.0,415.5,417.0,419.0]
+42	421.0	425.5	425.5	429.0	[421.0,425.5,428.0,429.0]
+43	430.0	435.0	435.0	439.0	[430.0,435.0,437.79999999999995,439.0]
+44	443.0	446.0	446.0	449.0	[443.0,446.0,447.6,449.0]
+45	452.0	455.0	455.0	459.0	[452.0,455.0,458.0,459.0]
+46	460.0	467.5	467.5	469.0	[460.0,467.5,468.0,469.0]
+47	470.0	477.0	477.0	479.0	[470.0,477.0,478.0,479.0]
+48	480.0	484.0	484.0	489.0	[480.0,484.0,487.79999999999995,489.0]
+49	490.0	494.5	494.5	498.0	[490.0,494.5,496.7,498.0]
+5	51.0	54.0	54.0	58.0	[51.0,54.0,57.199999999999996,58.0]
+6	64.0	66.5	66.5	69.0	[64.0,66.5,67.0,69.0]
+7	70.0	73.0	73.0	78.0	[70.0,73.0,76.0,78.0]
+8	80.0	84.0	84.0	87.0	[80.0,84.0,84.6,87.0]
+9	90.0	95.0	95.0	98.0	[90.0,95.0,97.0,98.0]
 PREHOOK: query: SELECT CAST(key AS INT) DIV 10,
        percentile_cont(NULL, 0.0),
        percentile_cont(0.0) WITHIN GROUP (ORDER BY NULL)
diff --git a/ql/src/test/results/clientpositive/udaf_percentile_disc.q.out b/ql/src/test/results/clientpositive/udaf_percentile_disc.q.out
index 83875ec..d10fee5 100644
--- a/ql/src/test/results/clientpositive/udaf_percentile_disc.q.out
+++ b/ql/src/test/results/clientpositive/udaf_percentile_disc.q.out
@@ -14,7 +14,8 @@ PREHOOK: query: SELECT CAST(key AS INT) DIV 10,
        percentile_disc(CAST(substr(value, 5) AS INT), 0.0),
        percentile_disc(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_disc(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS INT)),
-       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_disc(array(0.0, 0.5, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10
 PREHOOK: type: QUERY
@@ -24,67 +25,69 @@ POSTHOOK: query: SELECT CAST(key AS INT) DIV 10,
        percentile_disc(CAST(substr(value, 5) AS INT), 0.0),
        percentile_disc(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_disc(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS INT)),
-       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_disc(array(0.0, 0.5, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 #### A masked pattern was here ####
-0	0.0	5.0	5.0	9.0
-1	10.0	15.0	15.0	19.0
-10	100.0	103.0	103.0	105.0
-11	111.0	118.0	118.0	119.0
-12	120.0	128.0	128.0	129.0
-13	131.0	137.0	137.0	138.0
-14	143.0	146.0	146.0	149.0
-15	150.0	155.0	155.0	158.0
-16	160.0	167.0	167.0	169.0
-17	170.0	175.0	175.0	179.0
-18	180.0	187.0	187.0	189.0
-19	190.0	195.0	195.0	199.0
-2	20.0	26.0	26.0	28.0
-20	200.0	205.0	205.0	209.0
-21	213.0	217.0	217.0	219.0
-22	221.0	224.0	224.0	229.0
-23	230.0	235.0	235.0	239.0
-24	241.0	244.0	244.0	249.0
-25	252.0	256.0	256.0	258.0
-26	260.0	265.0	265.0	266.0
-27	272.0	275.0	275.0	278.0
-28	280.0	284.0	284.0	289.0
-29	291.0	298.0	298.0	298.0
-3	30.0	35.0	35.0	37.0
-30	302.0	307.0	307.0	309.0
-31	310.0	316.0	316.0	318.0
-32	321.0	325.0	325.0	327.0
-33	331.0	333.0	333.0	339.0
-34	341.0	345.0	345.0	348.0
-35	351.0	353.0	353.0	356.0
-36	360.0	367.0	367.0	369.0
-37	373.0	377.0	377.0	379.0
-38	382.0	384.0	384.0	389.0
-39	392.0	396.0	396.0	399.0
-4	41.0	43.0	43.0	47.0
-40	400.0	404.0	404.0	409.0
-41	411.0	417.0	417.0	419.0
-42	421.0	427.0	427.0	429.0
-43	430.0	435.0	435.0	439.0
-44	443.0	446.0	446.0	449.0
-45	452.0	455.0	455.0	459.0
-46	460.0	468.0	468.0	469.0
-47	470.0	477.0	477.0	479.0
-48	480.0	484.0	484.0	489.0
-49	490.0	495.0	495.0	498.0
-5	51.0	54.0	54.0	58.0
-6	64.0	67.0	67.0	69.0
-7	70.0	74.0	74.0	78.0
-8	80.0	84.0	84.0	87.0
-9	90.0	95.0	95.0	98.0
+0	0.0	5.0	5.0	9.0	[0.0,5.0,9.0]
+1	10.0	15.0	15.0	19.0	[10.0,15.0,19.0]
+10	100.0	103.0	103.0	105.0	[100.0,103.0,105.0]
+11	111.0	118.0	118.0	119.0	[111.0,118.0,119.0]
+12	120.0	128.0	128.0	129.0	[120.0,128.0,129.0]
+13	131.0	137.0	137.0	138.0	[131.0,137.0,138.0]
+14	143.0	146.0	146.0	149.0	[143.0,146.0,149.0]
+15	150.0	155.0	155.0	158.0	[150.0,155.0,158.0]
+16	160.0	167.0	167.0	169.0	[160.0,167.0,169.0]
+17	170.0	175.0	175.0	179.0	[170.0,175.0,179.0]
+18	180.0	187.0	187.0	189.0	[180.0,187.0,189.0]
+19	190.0	195.0	195.0	199.0	[190.0,195.0,199.0]
+2	20.0	26.0	26.0	28.0	[20.0,26.0,28.0]
+20	200.0	205.0	205.0	209.0	[200.0,205.0,209.0]
+21	213.0	217.0	217.0	219.0	[213.0,217.0,219.0]
+22	221.0	224.0	224.0	229.0	[221.0,224.0,229.0]
+23	230.0	235.0	235.0	239.0	[230.0,235.0,239.0]
+24	241.0	244.0	244.0	249.0	[241.0,244.0,249.0]
+25	252.0	256.0	256.0	258.0	[252.0,256.0,258.0]
+26	260.0	265.0	265.0	266.0	[260.0,265.0,266.0]
+27	272.0	275.0	275.0	278.0	[272.0,275.0,278.0]
+28	280.0	284.0	284.0	289.0	[280.0,284.0,289.0]
+29	291.0	298.0	298.0	298.0	[291.0,298.0,298.0]
+3	30.0	35.0	35.0	37.0	[30.0,35.0,37.0]
+30	302.0	307.0	307.0	309.0	[302.0,307.0,309.0]
+31	310.0	316.0	316.0	318.0	[310.0,316.0,318.0]
+32	321.0	325.0	325.0	327.0	[321.0,325.0,327.0]
+33	331.0	333.0	333.0	339.0	[331.0,333.0,339.0]
+34	341.0	345.0	345.0	348.0	[341.0,345.0,348.0]
+35	351.0	353.0	353.0	356.0	[351.0,353.0,356.0]
+36	360.0	367.0	367.0	369.0	[360.0,367.0,369.0]
+37	373.0	377.0	377.0	379.0	[373.0,377.0,379.0]
+38	382.0	384.0	384.0	389.0	[382.0,384.0,389.0]
+39	392.0	396.0	396.0	399.0	[392.0,396.0,399.0]
+4	41.0	43.0	43.0	47.0	[41.0,43.0,47.0]
+40	400.0	404.0	404.0	409.0	[400.0,404.0,409.0]
+41	411.0	417.0	417.0	419.0	[411.0,417.0,419.0]
+42	421.0	427.0	427.0	429.0	[421.0,427.0,429.0]
+43	430.0	435.0	435.0	439.0	[430.0,435.0,439.0]
+44	443.0	446.0	446.0	449.0	[443.0,446.0,449.0]
+45	452.0	455.0	455.0	459.0	[452.0,455.0,459.0]
+46	460.0	468.0	468.0	469.0	[460.0,468.0,469.0]
+47	470.0	477.0	477.0	479.0	[470.0,477.0,479.0]
+48	480.0	484.0	484.0	489.0	[480.0,484.0,489.0]
+49	490.0	495.0	495.0	498.0	[490.0,495.0,498.0]
+5	51.0	54.0	54.0	58.0	[51.0,54.0,58.0]
+6	64.0	67.0	67.0	69.0	[64.0,67.0,69.0]
+7	70.0	74.0	74.0	78.0	[70.0,74.0,78.0]
+8	80.0	84.0	84.0	87.0	[80.0,84.0,87.0]
+9	90.0	95.0	95.0	98.0	[90.0,95.0,98.0]
 PREHOOK: query: SELECT CAST(key AS INT) DIV 10,
        percentile_disc(CAST(substr(value, 5) AS INT), 0.0),
        percentile_disc(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_disc(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS INT)),
-       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_disc(array(0.0, 0.5, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10
 PREHOOK: type: QUERY
@@ -94,67 +97,69 @@ POSTHOOK: query: SELECT CAST(key AS INT) DIV 10,
        percentile_disc(CAST(substr(value, 5) AS INT), 0.0),
        percentile_disc(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_disc(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS INT)),
-       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_disc(array(0.0, 0.5, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 #### A masked pattern was here ####
-0	0.0	5.0	5.0	9.0
-1	10.0	15.0	15.0	19.0
-10	100.0	103.0	103.0	105.0
-11	111.0	118.0	118.0	119.0
-12	120.0	128.0	128.0	129.0
-13	131.0	137.0	137.0	138.0
-14	143.0	146.0	146.0	149.0
-15	150.0	155.0	155.0	158.0
-16	160.0	167.0	167.0	169.0
-17	170.0	175.0	175.0	179.0
-18	180.0	187.0	187.0	189.0
-19	190.0	195.0	195.0	199.0
-2	20.0	26.0	26.0	28.0
-20	200.0	205.0	205.0	209.0
-21	213.0	217.0	217.0	219.0
-22	221.0	224.0	224.0	229.0
-23	230.0	235.0	235.0	239.0
-24	241.0	244.0	244.0	249.0
-25	252.0	256.0	256.0	258.0
-26	260.0	265.0	265.0	266.0
-27	272.0	275.0	275.0	278.0
-28	280.0	284.0	284.0	289.0
-29	291.0	298.0	298.0	298.0
-3	30.0	35.0	35.0	37.0
-30	302.0	307.0	307.0	309.0
-31	310.0	316.0	316.0	318.0
-32	321.0	325.0	325.0	327.0
-33	331.0	333.0	333.0	339.0
-34	341.0	345.0	345.0	348.0
-35	351.0	353.0	353.0	356.0
-36	360.0	367.0	367.0	369.0
-37	373.0	377.0	377.0	379.0
-38	382.0	384.0	384.0	389.0
-39	392.0	396.0	396.0	399.0
-4	41.0	43.0	43.0	47.0
-40	400.0	404.0	404.0	409.0
-41	411.0	417.0	417.0	419.0
-42	421.0	427.0	427.0	429.0
-43	430.0	435.0	435.0	439.0
-44	443.0	446.0	446.0	449.0
-45	452.0	455.0	455.0	459.0
-46	460.0	468.0	468.0	469.0
-47	470.0	477.0	477.0	479.0
-48	480.0	484.0	484.0	489.0
-49	490.0	495.0	495.0	498.0
-5	51.0	54.0	54.0	58.0
-6	64.0	67.0	67.0	69.0
-7	70.0	74.0	74.0	78.0
-8	80.0	84.0	84.0	87.0
-9	90.0	95.0	95.0	98.0
+0	0.0	5.0	5.0	9.0	[0.0,5.0,9.0]
+1	10.0	15.0	15.0	19.0	[10.0,15.0,19.0]
+10	100.0	103.0	103.0	105.0	[100.0,103.0,105.0]
+11	111.0	118.0	118.0	119.0	[111.0,118.0,119.0]
+12	120.0	128.0	128.0	129.0	[120.0,128.0,129.0]
+13	131.0	137.0	137.0	138.0	[131.0,137.0,138.0]
+14	143.0	146.0	146.0	149.0	[143.0,146.0,149.0]
+15	150.0	155.0	155.0	158.0	[150.0,155.0,158.0]
+16	160.0	167.0	167.0	169.0	[160.0,167.0,169.0]
+17	170.0	175.0	175.0	179.0	[170.0,175.0,179.0]
+18	180.0	187.0	187.0	189.0	[180.0,187.0,189.0]
+19	190.0	195.0	195.0	199.0	[190.0,195.0,199.0]
+2	20.0	26.0	26.0	28.0	[20.0,26.0,28.0]
+20	200.0	205.0	205.0	209.0	[200.0,205.0,209.0]
+21	213.0	217.0	217.0	219.0	[213.0,217.0,219.0]
+22	221.0	224.0	224.0	229.0	[221.0,224.0,229.0]
+23	230.0	235.0	235.0	239.0	[230.0,235.0,239.0]
+24	241.0	244.0	244.0	249.0	[241.0,244.0,249.0]
+25	252.0	256.0	256.0	258.0	[252.0,256.0,258.0]
+26	260.0	265.0	265.0	266.0	[260.0,265.0,266.0]
+27	272.0	275.0	275.0	278.0	[272.0,275.0,278.0]
+28	280.0	284.0	284.0	289.0	[280.0,284.0,289.0]
+29	291.0	298.0	298.0	298.0	[291.0,298.0,298.0]
+3	30.0	35.0	35.0	37.0	[30.0,35.0,37.0]
+30	302.0	307.0	307.0	309.0	[302.0,307.0,309.0]
+31	310.0	316.0	316.0	318.0	[310.0,316.0,318.0]
+32	321.0	325.0	325.0	327.0	[321.0,325.0,327.0]
+33	331.0	333.0	333.0	339.0	[331.0,333.0,339.0]
+34	341.0	345.0	345.0	348.0	[341.0,345.0,348.0]
+35	351.0	353.0	353.0	356.0	[351.0,353.0,356.0]
+36	360.0	367.0	367.0	369.0	[360.0,367.0,369.0]
+37	373.0	377.0	377.0	379.0	[373.0,377.0,379.0]
+38	382.0	384.0	384.0	389.0	[382.0,384.0,389.0]
+39	392.0	396.0	396.0	399.0	[392.0,396.0,399.0]
+4	41.0	43.0	43.0	47.0	[41.0,43.0,47.0]
+40	400.0	404.0	404.0	409.0	[400.0,404.0,409.0]
+41	411.0	417.0	417.0	419.0	[411.0,417.0,419.0]
+42	421.0	427.0	427.0	429.0	[421.0,427.0,429.0]
+43	430.0	435.0	435.0	439.0	[430.0,435.0,439.0]
+44	443.0	446.0	446.0	449.0	[443.0,446.0,449.0]
+45	452.0	455.0	455.0	459.0	[452.0,455.0,459.0]
+46	460.0	468.0	468.0	469.0	[460.0,468.0,469.0]
+47	470.0	477.0	477.0	479.0	[470.0,477.0,479.0]
+48	480.0	484.0	484.0	489.0	[480.0,484.0,489.0]
+49	490.0	495.0	495.0	498.0	[490.0,495.0,498.0]
+5	51.0	54.0	54.0	58.0	[51.0,54.0,58.0]
+6	64.0	67.0	67.0	69.0	[64.0,67.0,69.0]
+7	70.0	74.0	74.0	78.0	[70.0,74.0,78.0]
+8	80.0	84.0	84.0	87.0	[80.0,84.0,87.0]
+9	90.0	95.0	95.0	98.0	[90.0,95.0,98.0]
 PREHOOK: query: SELECT CAST(key AS INT) DIV 10,
        percentile_disc(CAST(substr(value, 5) AS INT), 0.0),
        percentile_disc(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_disc(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS INT)),
-       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_disc(array(0.0, 0.5, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10
 PREHOOK: type: QUERY
@@ -164,67 +169,69 @@ POSTHOOK: query: SELECT CAST(key AS INT) DIV 10,
        percentile_disc(CAST(substr(value, 5) AS INT), 0.0),
        percentile_disc(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_disc(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS INT)),
-       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_disc(array(0.0, 0.5, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 #### A masked pattern was here ####
-0	0.0	5.0	5.0	9.0
-1	10.0	15.0	15.0	19.0
-10	100.0	103.0	103.0	105.0
-11	111.0	118.0	118.0	119.0
-12	120.0	128.0	128.0	129.0
-13	131.0	137.0	137.0	138.0
-14	143.0	146.0	146.0	149.0
-15	150.0	155.0	155.0	158.0
-16	160.0	167.0	167.0	169.0
-17	170.0	175.0	175.0	179.0
-18	180.0	187.0	187.0	189.0
-19	190.0	195.0	195.0	199.0
-2	20.0	26.0	26.0	28.0
-20	200.0	205.0	205.0	209.0
-21	213.0	217.0	217.0	219.0
-22	221.0	224.0	224.0	229.0
-23	230.0	235.0	235.0	239.0
-24	241.0	244.0	244.0	249.0
-25	252.0	256.0	256.0	258.0
-26	260.0	265.0	265.0	266.0
-27	272.0	275.0	275.0	278.0
-28	280.0	284.0	284.0	289.0
-29	291.0	298.0	298.0	298.0
-3	30.0	35.0	35.0	37.0
-30	302.0	307.0	307.0	309.0
-31	310.0	316.0	316.0	318.0
-32	321.0	325.0	325.0	327.0
-33	331.0	333.0	333.0	339.0
-34	341.0	345.0	345.0	348.0
-35	351.0	353.0	353.0	356.0
-36	360.0	367.0	367.0	369.0
-37	373.0	377.0	377.0	379.0
-38	382.0	384.0	384.0	389.0
-39	392.0	396.0	396.0	399.0
-4	41.0	43.0	43.0	47.0
-40	400.0	404.0	404.0	409.0
-41	411.0	417.0	417.0	419.0
-42	421.0	427.0	427.0	429.0
-43	430.0	435.0	435.0	439.0
-44	443.0	446.0	446.0	449.0
-45	452.0	455.0	455.0	459.0
-46	460.0	468.0	468.0	469.0
-47	470.0	477.0	477.0	479.0
-48	480.0	484.0	484.0	489.0
-49	490.0	495.0	495.0	498.0
-5	51.0	54.0	54.0	58.0
-6	64.0	67.0	67.0	69.0
-7	70.0	74.0	74.0	78.0
-8	80.0	84.0	84.0	87.0
-9	90.0	95.0	95.0	98.0
+0	0.0	5.0	5.0	9.0	[0.0,5.0,9.0]
+1	10.0	15.0	15.0	19.0	[10.0,15.0,19.0]
+10	100.0	103.0	103.0	105.0	[100.0,103.0,105.0]
+11	111.0	118.0	118.0	119.0	[111.0,118.0,119.0]
+12	120.0	128.0	128.0	129.0	[120.0,128.0,129.0]
+13	131.0	137.0	137.0	138.0	[131.0,137.0,138.0]
+14	143.0	146.0	146.0	149.0	[143.0,146.0,149.0]
+15	150.0	155.0	155.0	158.0	[150.0,155.0,158.0]
+16	160.0	167.0	167.0	169.0	[160.0,167.0,169.0]
+17	170.0	175.0	175.0	179.0	[170.0,175.0,179.0]
+18	180.0	187.0	187.0	189.0	[180.0,187.0,189.0]
+19	190.0	195.0	195.0	199.0	[190.0,195.0,199.0]
+2	20.0	26.0	26.0	28.0	[20.0,26.0,28.0]
+20	200.0	205.0	205.0	209.0	[200.0,205.0,209.0]
+21	213.0	217.0	217.0	219.0	[213.0,217.0,219.0]
+22	221.0	224.0	224.0	229.0	[221.0,224.0,229.0]
+23	230.0	235.0	235.0	239.0	[230.0,235.0,239.0]
+24	241.0	244.0	244.0	249.0	[241.0,244.0,249.0]
+25	252.0	256.0	256.0	258.0	[252.0,256.0,258.0]
+26	260.0	265.0	265.0	266.0	[260.0,265.0,266.0]
+27	272.0	275.0	275.0	278.0	[272.0,275.0,278.0]
+28	280.0	284.0	284.0	289.0	[280.0,284.0,289.0]
+29	291.0	298.0	298.0	298.0	[291.0,298.0,298.0]
+3	30.0	35.0	35.0	37.0	[30.0,35.0,37.0]
+30	302.0	307.0	307.0	309.0	[302.0,307.0,309.0]
+31	310.0	316.0	316.0	318.0	[310.0,316.0,318.0]
+32	321.0	325.0	325.0	327.0	[321.0,325.0,327.0]
+33	331.0	333.0	333.0	339.0	[331.0,333.0,339.0]
+34	341.0	345.0	345.0	348.0	[341.0,345.0,348.0]
+35	351.0	353.0	353.0	356.0	[351.0,353.0,356.0]
+36	360.0	367.0	367.0	369.0	[360.0,367.0,369.0]
+37	373.0	377.0	377.0	379.0	[373.0,377.0,379.0]
+38	382.0	384.0	384.0	389.0	[382.0,384.0,389.0]
+39	392.0	396.0	396.0	399.0	[392.0,396.0,399.0]
+4	41.0	43.0	43.0	47.0	[41.0,43.0,47.0]
+40	400.0	404.0	404.0	409.0	[400.0,404.0,409.0]
+41	411.0	417.0	417.0	419.0	[411.0,417.0,419.0]
+42	421.0	427.0	427.0	429.0	[421.0,427.0,429.0]
+43	430.0	435.0	435.0	439.0	[430.0,435.0,439.0]
+44	443.0	446.0	446.0	449.0	[443.0,446.0,449.0]
+45	452.0	455.0	455.0	459.0	[452.0,455.0,459.0]
+46	460.0	468.0	468.0	469.0	[460.0,468.0,469.0]
+47	470.0	477.0	477.0	479.0	[470.0,477.0,479.0]
+48	480.0	484.0	484.0	489.0	[480.0,484.0,489.0]
+49	490.0	495.0	495.0	498.0	[490.0,495.0,498.0]
+5	51.0	54.0	54.0	58.0	[51.0,54.0,58.0]
+6	64.0	67.0	67.0	69.0	[64.0,67.0,69.0]
+7	70.0	74.0	74.0	78.0	[70.0,74.0,78.0]
+8	80.0	84.0	84.0	87.0	[80.0,84.0,87.0]
+9	90.0	95.0	95.0	98.0	[90.0,95.0,98.0]
 PREHOOK: query: SELECT CAST(key AS INT) DIV 10,
        percentile_disc(CAST(substr(value, 5) AS INT), 0.0),
        percentile_disc(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_disc(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS INT)),
-       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_disc(array(0.0, 0.5, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10
 PREHOOK: type: QUERY
@@ -234,62 +241,63 @@ POSTHOOK: query: SELECT CAST(key AS INT) DIV 10,
        percentile_disc(CAST(substr(value, 5) AS INT), 0.0),
        percentile_disc(CAST(substr(value, 5) AS DOUBLE), 0.5),
        percentile_disc(0.5) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS INT)),
-       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0)
+       percentile_disc(CAST(substr(value, 5) AS DECIMAL), 1.0),
+       percentile_disc(array(0.0, 0.5, 1.0)) WITHIN GROUP (ORDER BY CAST(substr(value, 5) AS DOUBLE))
 FROM src
 GROUP BY CAST(key AS INT) DIV 10
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@src
 #### A masked pattern was here ####
-0	0.0	5.0	5.0	9.0
-1	10.0	15.0	15.0	19.0
-10	100.0	103.0	103.0	105.0
-11	111.0	118.0	118.0	119.0
-12	120.0	128.0	128.0	129.0
-13	131.0	137.0	137.0	138.0
-14	143.0	146.0	146.0	149.0
-15	150.0	155.0	155.0	158.0
-16	160.0	167.0	167.0	169.0
-17	170.0	175.0	175.0	179.0
-18	180.0	187.0	187.0	189.0
-19	190.0	195.0	195.0	199.0
-2	20.0	26.0	26.0	28.0
-20	200.0	205.0	205.0	209.0
-21	213.0	217.0	217.0	219.0
-22	221.0	224.0	224.0	229.0
-23	230.0	235.0	235.0	239.0
-24	241.0	244.0	244.0	249.0
-25	252.0	256.0	256.0	258.0
-26	260.0	265.0	265.0	266.0
-27	272.0	275.0	275.0	278.0
-28	280.0	284.0	284.0	289.0
-29	291.0	298.0	298.0	298.0
-3	30.0	35.0	35.0	37.0
-30	302.0	307.0	307.0	309.0
-31	310.0	316.0	316.0	318.0
-32	321.0	325.0	325.0	327.0
-33	331.0	333.0	333.0	339.0
-34	341.0	345.0	345.0	348.0
-35	351.0	353.0	353.0	356.0
-36	360.0	367.0	367.0	369.0
-37	373.0	377.0	377.0	379.0
-38	382.0	384.0	384.0	389.0
-39	392.0	396.0	396.0	399.0
-4	41.0	43.0	43.0	47.0
-40	400.0	404.0	404.0	409.0
-41	411.0	417.0	417.0	419.0
-42	421.0	427.0	427.0	429.0
-43	430.0	435.0	435.0	439.0
-44	443.0	446.0	446.0	449.0
-45	452.0	455.0	455.0	459.0
-46	460.0	468.0	468.0	469.0
-47	470.0	477.0	477.0	479.0
-48	480.0	484.0	484.0	489.0
-49	490.0	495.0	495.0	498.0
-5	51.0	54.0	54.0	58.0
-6	64.0	67.0	67.0	69.0
-7	70.0	74.0	74.0	78.0
-8	80.0	84.0	84.0	87.0
-9	90.0	95.0	95.0	98.0
+0	0.0	5.0	5.0	9.0	[0.0,5.0,9.0]
+1	10.0	15.0	15.0	19.0	[10.0,15.0,19.0]
+10	100.0	103.0	103.0	105.0	[100.0,103.0,105.0]
+11	111.0	118.0	118.0	119.0	[111.0,118.0,119.0]
+12	120.0	128.0	128.0	129.0	[120.0,128.0,129.0]
+13	131.0	137.0	137.0	138.0	[131.0,137.0,138.0]
+14	143.0	146.0	146.0	149.0	[143.0,146.0,149.0]
+15	150.0	155.0	155.0	158.0	[150.0,155.0,158.0]
+16	160.0	167.0	167.0	169.0	[160.0,167.0,169.0]
+17	170.0	175.0	175.0	179.0	[170.0,175.0,179.0]
+18	180.0	187.0	187.0	189.0	[180.0,187.0,189.0]
+19	190.0	195.0	195.0	199.0	[190.0,195.0,199.0]
+2	20.0	26.0	26.0	28.0	[20.0,26.0,28.0]
+20	200.0	205.0	205.0	209.0	[200.0,205.0,209.0]
+21	213.0	217.0	217.0	219.0	[213.0,217.0,219.0]
+22	221.0	224.0	224.0	229.0	[221.0,224.0,229.0]
+23	230.0	235.0	235.0	239.0	[230.0,235.0,239.0]
+24	241.0	244.0	244.0	249.0	[241.0,244.0,249.0]
+25	252.0	256.0	256.0	258.0	[252.0,256.0,258.0]
+26	260.0	265.0	265.0	266.0	[260.0,265.0,266.0]
+27	272.0	275.0	275.0	278.0	[272.0,275.0,278.0]
+28	280.0	284.0	284.0	289.0	[280.0,284.0,289.0]
+29	291.0	298.0	298.0	298.0	[291.0,298.0,298.0]
+3	30.0	35.0	35.0	37.0	[30.0,35.0,37.0]
+30	302.0	307.0	307.0	309.0	[302.0,307.0,309.0]
+31	310.0	316.0	316.0	318.0	[310.0,316.0,318.0]
+32	321.0	325.0	325.0	327.0	[321.0,325.0,327.0]
+33	331.0	333.0	333.0	339.0	[331.0,333.0,339.0]
+34	341.0	345.0	345.0	348.0	[341.0,345.0,348.0]
+35	351.0	353.0	353.0	356.0	[351.0,353.0,356.0]
+36	360.0	367.0	367.0	369.0	[360.0,367.0,369.0]
+37	373.0	377.0	377.0	379.0	[373.0,377.0,379.0]
+38	382.0	384.0	384.0	389.0	[382.0,384.0,389.0]
+39	392.0	396.0	396.0	399.0	[392.0,396.0,399.0]
+4	41.0	43.0	43.0	47.0	[41.0,43.0,47.0]
+40	400.0	404.0	404.0	409.0	[400.0,404.0,409.0]
+41	411.0	417.0	417.0	419.0	[411.0,417.0,419.0]
+42	421.0	427.0	427.0	429.0	[421.0,427.0,429.0]
+43	430.0	435.0	435.0	439.0	[430.0,435.0,439.0]
+44	443.0	446.0	446.0	449.0	[443.0,446.0,449.0]
+45	452.0	455.0	455.0	459.0	[452.0,455.0,459.0]
+46	460.0	468.0	468.0	469.0	[460.0,468.0,469.0]
+47	470.0	477.0	477.0	479.0	[470.0,477.0,479.0]
+48	480.0	484.0	484.0	489.0	[480.0,484.0,489.0]
+49	490.0	495.0	495.0	498.0	[490.0,495.0,498.0]
+5	51.0	54.0	54.0	58.0	[51.0,54.0,58.0]
+6	64.0	67.0	67.0	69.0	[64.0,67.0,69.0]
+7	70.0	74.0	74.0	78.0	[70.0,74.0,78.0]
+8	80.0	84.0	84.0	87.0	[80.0,84.0,87.0]
+9	90.0	95.0	95.0	98.0	[90.0,95.0,98.0]
 PREHOOK: query: SELECT CAST(key AS INT) DIV 10,
        percentile_disc(NULL, 0.0),
        percentile_disc(0.0) WITHIN GROUP (ORDER BY NULL)